Repository navigation
[Unicode] Shrink the property range pool by 34.9% - #2342
Open
andre-rosa wants to merge 3 commits into
Open
andre-rosa wants to merge 3 commits into
andre-rosa wants to merge 3 commits into
Conversation
Summary: Keep the range deltas and block resets introduced in d41288d. Encode short gap and length pairs as one byte and use a tagged fallback for larger values. Generate the bytes and offsets in genUnicodeTable.py and decode them when constructing regex character sets. The generated Unicode 17.0 range pool shrinks from 39,660 to 29,810 bytes. The decoder preserves aliases, shared references and range boundaries without allocating a decoded cache. Test Plan: Regenerate the pool and references from the 13 pinned Unicode inputs and independently compare the decoded endpoints of all 356 references with upstream. Check output and bytecode equality for both Unicode regex fixtures.
Summary: Reserve one short-pair tag for runs of singletons separated by one code point. Emit it only when it reduces the encoded size. Limit expansion to the active reference length so a reference can consume a prefix of a shared block. The generated range pool falls from 29,810 to 25,819 bytes. Test Plan: Regenerate the pool and references, compare decoded endpoints with upstream, and verify fixture output and bytecode equality. Compare linked size and Unicode regex construction across ULEB128, pairs, and pairs plus the run token on x86-64 and ARMv7 Thumb-2.
Use the generated range counts to reserve room before building an empty set. Reserve the exact complement count when inserting into an empty receiver. Existing nonempty sets can contain overlapping ranges, so leave their allocation policy unchanged.
Author
This branch has not been deployed
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.
Summary
Building on the upstream ULEB128 encoding, this series shrinks the Unicode property range pool from 39,660 to 25,819 bytes and saves 14,952 bytes in the stripped ARMv7 Thumb-2 CLI.
Before ULEB128, the pool occupied 145,632 bytes. The two changes together save 119,813 bytes (82.3%) relative to that original representation. Upstream ULEB128 change
The series has three independently reviewable commits.
genUnicodeTable.pyemits the encoded bytes and reference offsets. C++ decodes the table while constructing regex character sets. The encoding preserves range endpoints, aliases, shared references, and block resets.Size and compile time
Capacity reservation adds 64 bytes to the stripped ARMv7 CLI relative to the first two commits. Reserving before insertion avoids intermediate range-buffer growth and the copies that occur when growth moves the buffer. In separate x86-64 instrumentation trials, upstream and the first two commits each made 404,844 process-wide
realloccalls. The full series made 184,984 calls, a reduction of 54.3%. The instrumentation counted calls torealloc.The table shows the full series versus upstream. Values are median paired changes, with interquartile intervals in brackets. Negative values mean less time.
The ARMv7 build used
-Os, LTO, and Thumb-2. All variants ran the same benchmark bytecode in balanced execution orders, with six samples per variant on ARMv7 and twelve on x86-64. The timed loop measurednew RegExpconstruction. Matching ran outside the timed region.Test plan
It follows the generation-time packing approach discussed in the earlier PR. The commit split shows the effects of one-byte pairs, the run token, and reservation separately. PR #2300