Repository navigation
Conversation
Owner
|
Landed via batch PR #6439 (merged) — closing as superseded. |
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.
Fixes #6248
Problem
A necessary cold SimHash evaluation currently allocates every consecutive word pair, then consumes only the uniformly sampled subset (at most 256 features). A million-word input creates 999,999 bigram strings even though almost all are discarded unused. This adds substantial allocation and garbage collection for long messages.
Change
Compute the feature count and stride directly from token count and construct a bigram only when it is sampled. The sample positions, Unicode tokenization, unigram/raw-input fallbacks and 16-bit vote counters stay unchanged. Token storage remains linear; this removes the redundant full-size shingle array.
Golden sketches captured from the old implementation cover distinct tokens around stride boundaries, 100,000 tokens, Unicode and degenerate inputs. The manual benchmark runs the production function and reports the sketch so before/after compatibility is visible:
Validation
047251b26ebac679.npm run typecheck,npm run build, andgit diff --check: passed.Based independently on current master
dc041dd1ab1a014efa352ba47a6f31fc47f55284. Prior #6046 fixes vote overflow and #2828 skips unnecessary calls; this patch removes unused shingle allocation inside necessary evaluations.