[generator.c] use a conditional to select SIMD implementation rather than pointer#923
Merged
byroot merged 2 commits intoruby:masterfrom Jan 14, 2026
Merged
Conversation
samyron
commented
Jan 14, 2026
| search.matches_mask = 0; | ||
| search.has_matches = false; | ||
| search.chunk_base = NULL; | ||
| search.chunk_end = NULL; |
Contributor
Author
There was a problem hiding this comment.
Now that this is being inlined on gcc it emitted a warning about chunk_end potentially being uninitialized when compiling on Linux.
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.
This aligns the SIMD dispatch mechanism between the generator and the parser. The generator was implemented using function pointers to determine which
search_escape_basic*to call. When implementing the parser, I noticed using conditionals was faster when compiling ongcconaarch64. I never did circle back to the generator.Run on my M1 Macbook Air - I did run these on my Macbook Pro with an M4 and saw pretty much the same increase):
The performance benefit comes from (at least) inlining
search_escape_basic_neon. There might be better code generation decisions made as a result of that inlining too.Interestingly
clangdid inline the code when using function pointers.I do realize that
clangis the default compiler on MacOS so I would not expect this to affect too many developers on their machine. However, deploying to production using Linux will likely benefit from this asgccis often (always?) the default compiler. The offical Ruby Docker images are built with gcc.Testing this locally with an Ubuntu image: