Skip to content

perf(mbstring): share one immutable encoding catalog - #1885

Merged
nahime0 merged 1 commit into
mainfrom
feat/shared-mbstring-catalog
Oct 19, 2026
Merged

nahime0 merged 1 commit into
mainfrom
feat/shared-mbstring-catalog

Conversation

@nahime0

@nahime0 nahime0 commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

The generated encoding catalog is a const slice containing all codec byte tables. Multiple consumers instantiate those tables repeatedly in the mbstring bridge. Make the catalog one immutable static and preserve that policy in the generator. Encoding order, aliases, codecs and table bytes are unchanged.

On Linux x86_64 with isolated release bridge builds, the standalone mbstring archive decreases from 144,674,846 to 39,858,218 bytes. Using the same compiler, source path and other bridges, a two-line opaque-eval executable decreases from 136,183,056 to 32,095,504 bytes in default stripped mode (76.4% smaller), or 147,036,640 to 42,784,824 bytes with symbols. The eval-free catalog/codec probe decreases from 123,029,256 to 18,781,504 bytes with heap debug and symbols. These are footprint measurements, not execution-time speedup claims.

Validation: all four catalog tests and 80 codec corpus tests pass against the captured PHP oracle. The catalog/codec probe matches real PHP8.5.11 with optimizer on/off and clean heap-debug summaries. Regeneration is repeatable and git diff --check passes. Add the probe under benchmark/diagnostics for reproducing the linked footprint.

Seven alternating warm-cache compilation pairs of the same opaque-eval source, with before/after compiler/linker process guards, measure median process time 7.477 to 7.079 seconds and median linking time 917.77 to 770.88 ms. All measured phase MAD/median ratios are below 2.72%. Code generation and assembly confidence intervals overlap parity; this change reduces linked data without removing their helper generation work.

@github-actions github-actions Bot added area:runtime Touches runtime helpers, GC, ownership, or bridge runtimes. area:tooling-ci Touches CI, development tooling, Docker, or repository scripts. size:s Small pull request. type:feature Introduces new user-visible behavior or capabilities. labels Oct 18, 2026
@nahime0
nahime0 marked this pull request as ready for review October 18, 2026 21:44
@nahime0

nahime0 commented Oct 18, 2026

Copy link
Copy Markdown
Member Author

@greptileai please review the current head f5aa2c9.

@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no actionable issues were found.

Summary

Changes ENCODINGS from a const slice to one immutable static, and updates the generator to preserve that choice.

  • The mbstring bridge stores its encoding catalog once.
  • A PHP probe exercises mbstring for footprint comparisons.

Reviews (1) · Last reviewed commit: "perf(mbstring): share one immutable enco..." · Reviewed by Greptile

@nahime0
nahime0 merged commit e90ed5e into main Oct 19, 2026
192 checks passed
@nahime0
nahime0 deleted the feat/shared-mbstring-catalog branch October 19, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Touches runtime helpers, GC, ownership, or bridge runtimes. area:tooling-ci Touches CI, development tooling, Docker, or repository scripts. size:s Small pull request. type:feature Introduces new user-visible behavior or capabilities.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant