-
-
Notifications
You must be signed in to change notification settings - Fork 608
Feat/hash serialization #1382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexander-akait
merged 2 commits into
webpack-contrib:master
from
subzey:feat/hash-serialization
Oct 9, 2021
Merged
Feat/hash serialization #1382
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am afraid only for perf here, create multiple times hash is not good idea, can you explain why we need create it again and again and do not reuse existing hash?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 2nd iteration is only required if the digest length is not enough to generate a pseudorandom string long enough.
If we won't change anything between the iterations then each iteration would generate the same output over and over and the string would just cycle:
If
hash(str) = "ABCDE"
, then it would be"ABCDEABCDEABCDEA"
. Even if this str is 16 chars long its "uniqueness" is only 5 chars long.I've ran
npm test:only
logging the number of times this loop iterated per function call.1375 calls only ran this loop once.122 twice.2 calls took three iterationsUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upd: My bad,
jest
spawns 4 processes and they were concurrently writing the same file 😓1672 - 1 time
125 - 2 times
2 - 3 times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've investigated those two suspicious calls where the loop is iterated 3 times.
It's my own
xxhash64
test from this very PR. I'm asking a hex digest of length 20 (= 80bits) from a digest that can only produce 64 bits and have a really high chance to produce a long run of leading digits.Iteration 0:
digest
is7268299549203d4d
Leading digits are dropped, the resulting string so far is:
7268299549203
d4d
Iteration 1:
digest
is26a899717294ba28
=>7268299549203
d4d
26a899717294ba28
Iteration 2:
digest
is45400c2599876c30
. The string is trimmed at length 20:7268299549203
d4d
26a899717294ba28
4
5400c2599876c30