Skip to content

v0.6.2: ASCII character classification lookup tables - #79

Merged
tamnd merged 1 commit into
mainfrom
v0.6.2
Apr 28, 2026
Merged

v0.6.2: ASCII character classification lookup tables#79
tamnd merged 1 commit into
mainfrom
v0.6.2

Conversation

@tamnd

@tamnd tamnd commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace utf8.DecodeRuneInString + unicode.IsLetter in the identifier scan hot loop with 128-entry byte-indexed lookup tables for ASCII bytes
  • Non-ASCII (>= 0x80) still uses the unicode-aware path
  • identStartTable[128]bool: a-z A-Z _
  • identContTable[128]bool: a-z A-Z 0-9 _

Throughput (Apple M4, 10 cores, in-memory benchmark)

MB/s vs CPython serial
v0.6.1 serial 43.9 4.3x
v0.6.2 serial 53.6 5.3x
v0.6.1 parallel 220.8 21.6x
v0.6.2 parallel 240.3 23.5x
CPython serial baseline 10.2 1x

+22% on serial; +9% on parallel. Wall-clock gopapy bench corpus/src: 262 MB/s (25.7x CPython).

Test plan

  • go test ./... passes
  • All oracle tests pass (3.8–3.14, ubuntu/macos/windows)
  • Stdlib parse passes (3.8–3.13)
  • Corpus parse/roundtrip/astdiff pass

Replace utf8.DecodeRuneInString + unicode.IsLetter in the identifier
scan hot loop with 128-entry byte-indexed table lookups for ASCII bytes.
Non-ASCII bytes (>= 0x80) still fall through to the unicode-aware path.

identStartTable[c]: true for a-z A-Z _
identContTable[c]:  true for a-z A-Z 0-9 _

+22% serial throughput on Apple M4: 43.9 → 53.6 MB/s in-memory.
Parallel: 220.8 → 240.3 MB/s.
@tamnd
tamnd merged commit e620b06 into main Apr 28, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant