Repository navigation
perf: index fixed string lists in the in operator - #72
Open
siddarthaboddu wants to merge 1 commit into
Open
siddarthaboddu wants to merge 1 commit into
siddarthaboddu wants to merge 1 commit into
Conversation
Build a membership index for lists of at least 16 string literals so repeated evaluations can reuse it. Discard the index when an iterator or sublist can mutate the parsed list. Cover localized error paths, custom operations, missing codes, and edits to parsed rules.
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.
A filter can evaluate the same list of allowed codes once for every record. For lists containing at least 16 literal strings, build a membership index when parsing the rule and reuse it for string or null lookups. Returning a mutable iterator or sublist discards the index so subsequent evaluations observe edits.
Performance
Single-threaded JMH 1.37 on Java 21. Both builds use cached rules and identical inputs. A filter operation processes all 256 records. The last two rows measure one lookup in a Java list supplied as data.
Compatibility and tradeoffs
The same 119 JUnit tests passed on main and the candidate on Java 8 and 21. All 843 differential cases matched on each JVM, including exception types, messages and paths. Twenty parsed-rule mutation cases passed on both builds. Tests also cover custom operators, localized paths and exceptions from later data-list reads. The index uses additional memory for the lifetime of an eligible cached rule. The intended speedup is for repeated lookups in fixed string lists.
Reproduce the filter benchmark
Compile the following class with JMH 1.37 and its annotation processor against each revision. Run on Java 21 with the same heap and GC profiler.