Repository navigation
perf(mbstring): share one immutable encoding catalog - #1885
Merged
Merged
Conversation
nahime0
marked this pull request as ready for review
October 18, 2026 21:44
Member
Author
|
@greptileai please review the current head f5aa2c9. |
Contributor
[Medium impact] This PR appears safe to merge; no actionable issues were found. SummaryChanges
Reviews (1) · Last reviewed commit: "perf(mbstring): share one immutable enco..." · Reviewed by Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.