Split String::eq into fast path + slow path for inlining#726
Merged
Conversation
Separate the length check (fast path, small enough to inline) from the byte-by-byte comparison loop (eq_bytes, separate function). This allows the compiler to inline the length mismatch early-exit into callers, avoiding the function call overhead when strings differ in length. Benchmark: gale gen SQLite.g4 improved from 4m13s to 1m04s (~4x faster). https://claude.ai/code/session_01Mz8z6W978jr8Ad5x9nDoat
Working tree is dirtyIntegrity checks produced the following changes: Please run |
Regenerated by `mise run on-task-done`. All 1315 tests pass. https://claude.ai/code/session_01Mz8z6W978jr8Ad5x9nDoat
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
String^Eq::eqinto a small fast path (length comparison only) and a separateeq_bytesslow path (byte-by-byte loop)Benchmark
gale gen SQLite.g4(string-comparison-heavy workload):Guest profiler showed
String^Eq::eqat 28% inclusive time. Most calls in this workload compare strings of different lengths (e.g.array_contains_strscanning token arrays), so the length mismatch early-exit dominates.Test plan
cargo test --release -p wado-compiler— all tests passhttps://claude.ai/code/session_01Mz8z6W978jr8Ad5x9nDoat