Skip to content

Optimize UTF-8 decode #163144

Todo

Description

@methane
  • Using memcpy lets us process the input regardless of alignment, avoiding the byte-by-byte loop up to the next aligned address. This speeds up short runs and simplifies the code.
  • Use SIMD to decode consecutive UTF-8 characters of the same byte length.
  • Decode short strings into a stack buffer instead of counting their code points first.
  • Use unicode_char() when the input decodes to a single character.

Linked PRs

Activity

  1. self-assigned this
    on Dec 4, 2026
  2. added
    performance
    interpreter-core
    on Dec 4, 2026
  3. changed the title [-]optimize UTF-8 decode[/-] [+]Optimize UTF-8 decode[/+] on Dec 4, 2026
  4. picnixz commented on Dec 4, 2026

    @picnixz
    Member

    Use SIMD to decode consecutive UTF-8 characters of the same byte length.

    Can you avoid that as the first iteration? the core dev team is still debating whether to add SIMD in general (see #124951 for instance).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-coreperformancetopic-unicode

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions