Repository navigation
Conversation
headius
force-pushed
the
work/unicode-casecmp-perf
branch
from
October 30, 2026 08:43
099c011 to
fc3416b
Compare
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.
Stream validated UTF-8 case folds into bounded buffers instead of allocating folded Strings. Validate both complete inputs before returning on a mismatch; other encodings retain the existing path. Separate from #9955.
The first commit fixes missing result length in multi-buffer case mapping:
("ΐ" * 4).downcase(:fold)previously became empty. Both changes have portable Ruby specs.Historical benchmark-ips 2.15.1 results from before the rebase, iterations/second (higher is better). Baseline:
07e498eb6aplus the standalone mapping-length fix, before master gained #9955's direct ASCII fast path. Candidate: original PR head099c0118a8.Linux x86_64/i7-10850H, Temurin 21.0.13+9, normal JIT, 512 MB heap; three JVMs/variant, alternating order, 2 s warmup/3 s measurement per case. Rates are medians of per-process benchmark-ips reports; ratios use those displayed medians. Fresh cases include construction; no reused-string encoding-reset timings are used here.
The large mismatch gain is early exit, not full-string folding throughput. Changed-case dense results vary by fork: one pair regressed 20%. A matched benchmark-ips control on CRuby 4.1dev
d8444812f4achieved 14,637 ips versus this PR’s 8,835 ips on that workload; universal CRuby parity is not achieved.Reproduce:
WARMUP=2 TIME=3 bin/jruby -J-Xms512m -J-Xmx512m bench/bench_string_casecmp_unicode.rb LABEL SAVE_PREFIX.Validation: 84 examples/169 expectations pass interpreted, forced-compiled and CRuby 4.0.9; 1,112,064 Unicode scalars, 200,000 sequence comparisons, 100,000 valid/malformed-byte pairs, 2,266 encoding cases and shared-slice checks pass.
Rebased onto master
db5b9ef6d9on 2026-10-30. Upstream's ASCII fast path runs first; the compact UTF-8 helper and separate mapping-length fix are unchanged. Both upstream ASCII and Unicode specs are retained. After rebase, 95 examples/199 expectations pass in interpreted and forced-compiled JRuby; each mode also passes 2,266 encoding differential cases, 2,000 valid/malformed UTF-8 comparisons against full folding, and 30 frozen shared-slice checks with verified nonzero offsets. Earlier exhaustive Unicode validation was not repeated because the folding helper and correctness fix are unchanged.The benchmark table above records the original pre-rebase comparison against its correctness-fix-only baseline. Master now includes the ASCII optimization; these historical figures are not a new comparison against current master. No benchmarks were rerun for this rebase.
Current master includes #9955's direct ASCII fast path, which returns before UTF-8 streaming. The former fresh-ASCII comparison used the older pre-ASCII baseline and does not establish an incremental gain from this rebased PR; ASCII rows have been removed from this table. The portable runner remains available for new comparisons.