-
Notifications
You must be signed in to change notification settings - Fork 77
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
Expose the precomputed hash using a trait so that I can use it from rust-selectors. #183
Conversation
r? @nox I'm not super-happy about this, but it's the best way I found to keep |
This is not a pre-computed hash. |
In each case, neither Creating an atom involves hashing the string with |
How would you feel about using the upper bytes for the inline atoms, and storing the hash for the non-inline ones? |
@SimonSapin Do you mind answering @emilio's question? This is blocking servo/servo#16070 which is blocking the investigation in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935 so it would be good to get some motion here... |
Ah, sorry I let this slip through. Yes, go ahead. For inline atoms that doesn’t sound like a great hash, but maybe that’s ok. (Is even XORing the two halves too costly?) |
Ammended that way, and yeah, for inline atoms xoring should be fine. r? @SimonSapin |
Oh, and if the question re. XORing was wrt the current bloom filter. The answer is that right now we're sip-hashing the hash all the time, which is what this PR is trying to avoid. |
Looks good overall. Some details: Reviewed 5 of 5 files at r1. src/atom.rs, line 180 at r1 (raw file):
Maybe make this src/atom.rs, line 193 at r1 (raw file):
Maybe make this src/atom.rs, line 271 at r1 (raw file):
I’m not sure about this change. If this is going through another hasher anyway there is not much use re-using the pre-computed hash. And giving 32 bits to that hasher instead of 64 bits seems slightly worse, but maybe that also doesn’t matter? Comments from Reviewable |
…ust-selectors. This allows us to get rid of the extra hashing overhead every time we check the bloom filter.
Review status: all files reviewed at latest revision, 3 unresolved discussions. src/atom.rs, line 180 at r1 (raw file): Previously, SimonSapin (Simon Sapin) wrote…
Done. src/atom.rs, line 193 at r1 (raw file): Previously, SimonSapin (Simon Sapin) wrote…
Sounds good, I did that. I don't think it matters fwiw, but... src/atom.rs, line 271 at r1 (raw file): Previously, SimonSapin (Simon Sapin) wrote…
Ok, reverted. Also it's unclear to me whether it really matters, but sounds fine. Comments from Reviewable |
Thanks! @bors-servo r+ Reviewed 2 of 2 files at r2. Comments from Reviewable |
@bors-servo r=SimonSapin |
Oh, great, bors is dead? |
@bors-servo r+ Clicked "Synchronize" on http://build.servo.org/homu/queue/string-cache |
📌 Commit f7ce843 has been approved by |
Expose the precomputed hash using a trait so that I can use it from rust-selectors. This allows us to get rid of the extra hashing overhead every time we check the bloom filter. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/string-cache/183) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
selectors: Get rid of hashing overhead using the precomputed hash atoms have. I realized of this when @bzbarsky mentioned the bloom filter in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935#c7. Right now we hash (the hash) all the time, when we can do better. This requires a change in string-cache, which is at servo/string-cache#183. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16070) <!-- Reviewable:end -->
selectors: Get rid of hashing overhead using the precomputed hash atoms have. I realized of this when @bzbarsky mentioned the bloom filter in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935#c7. Right now we hash (the hash) all the time, when we can do better. This requires a change in string-cache, which is at servo/string-cache#183. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16070) <!-- Reviewable:end -->
selectors: Get rid of hashing overhead using the precomputed hash atoms have. I realized of this when @bzbarsky mentioned the bloom filter in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935#c7. Right now we hash (the hash) all the time, when we can do better. This requires a change in string-cache, which is at servo/string-cache#183. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16070) <!-- Reviewable:end -->
…e precomputed hash atoms have (from emilio:selectors-bloom-hash-less); r=bholley I realized of this when @bzbarsky mentioned the bloom filter in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935#c7. Right now we hash (the hash) all the time, when we can do better. This requires a change in string-cache, which is at servo/string-cache#183. Source-Repo: https://github.com/servo/servo Source-Revision: a811776df478a009ac6a7785ad13684e3a8e0925 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : a84fb1b7a5ccab19ecfa8bb57499719f881fd1c1
…e precomputed hash atoms have (from emilio:selectors-bloom-hash-less); r=bholley I realized of this when @bzbarsky mentioned the bloom filter in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935#c7. Right now we hash (the hash) all the time, when we can do better. This requires a change in string-cache, which is at servo/string-cache#183. Source-Repo: https://github.com/servo/servo Source-Revision: a811776df478a009ac6a7785ad13684e3a8e0925
…e precomputed hash atoms have (from emilio:selectors-bloom-hash-less); r=bholley I realized of this when @bzbarsky mentioned the bloom filter in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935#c7. Right now we hash (the hash) all the time, when we can do better. This requires a change in string-cache, which is at servo/string-cache#183. Source-Repo: https://github.com/servo/servo Source-Revision: a811776df478a009ac6a7785ad13684e3a8e0925
…e precomputed hash atoms have (from emilio:selectors-bloom-hash-less); r=bholley I realized of this when bzbarsky mentioned the bloom filter in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935#c7. Right now we hash (the hash) all the time, when we can do better. This requires a change in string-cache, which is at servo/string-cache#183. Source-Repo: https://github.com/servo/servo Source-Revision: a811776df478a009ac6a7785ad13684e3a8e0925 UltraBlame original commit: 61af2690f34f238d0ce4f0b2a808f5d530581f76
…e precomputed hash atoms have (from emilio:selectors-bloom-hash-less); r=bholley I realized of this when bzbarsky mentioned the bloom filter in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935#c7. Right now we hash (the hash) all the time, when we can do better. This requires a change in string-cache, which is at servo/string-cache#183. Source-Repo: https://github.com/servo/servo Source-Revision: a811776df478a009ac6a7785ad13684e3a8e0925 UltraBlame original commit: 61af2690f34f238d0ce4f0b2a808f5d530581f76
…e precomputed hash atoms have (from emilio:selectors-bloom-hash-less); r=bholley I realized of this when bzbarsky mentioned the bloom filter in https://bugzilla.mozilla.org/show_bug.cgi?id=1348935#c7. Right now we hash (the hash) all the time, when we can do better. This requires a change in string-cache, which is at servo/string-cache#183. Source-Repo: https://github.com/servo/servo Source-Revision: a811776df478a009ac6a7785ad13684e3a8e0925 UltraBlame original commit: 61af2690f34f238d0ce4f0b2a808f5d530581f76
This allows us to get rid of the extra hashing overhead every time we check the
bloom filter.
This change is