perf: cached repeated strict token lookups per input - #178
Merged
Conversation
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
Validation
npm cinpm test -- tests/strict-token-index.spec.ts tests/api.spec.ts tests/scanner.spec.ts tests/runtime-literals.spec.ts tests/normalization.spec.ts tests/internal-rules.spec.tsnpm run checknpm run benchmark:strict-lookupwith the same harness onorigin/mainand this branchnpm run benchmark:profanityonorigin/mainand this branch with the same machine and command shapeBenchmark Evidence
Baseline
origin/main:createProfanityFilter(): 7.1879 avg msThis branch:
createProfanityFilter(): 7.2239 avg msRepeated clean lookup improved by about 25.4%, repeated match analysis by about 3.0%, general long clean by about 7.4%, and the repeated long-late fixture by about 54.6%. The unique-token negative control measured about 5.3% overhead, with no change to its 300 required indexed evaluations; the cache is lazy for up to two distinct tokens and remains bounded by the current input.
Compatibility Notes
Closes #172
No publish, no merge, no tag/release.