Closed
Bug 1483062
Opened 8 years ago
Closed 8 years ago
A couple more mozilla::HashTable tweaks
Categories
(Core :: MFBT, enhancement)
Core
MFBT
Tracking
()
RESOLVED
FIXED
mozilla63
| Tracking | Status | |
|---|---|---|
| firefox63 | --- | fixed |
People
(Reporter: n.nethercote, Assigned: n.nethercote)
Details
Attachments
(7 files, 1 obsolete file)
|
1.13 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
|
2.91 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
|
5.75 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
|
2.08 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
|
1.88 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
|
1.59 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
|
3.61 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
No description provided.
| Assignee | ||
Updated•8 years ago
|
Assignee: nobody → n.nethercote
Status: NEW → ASSIGNED
| Assignee | ||
Comment 2•8 years ago
|
||
Because that's a more accurate description of what it does -- it finds free
*and* removed entries.
Attachment #8999826 -
Flags: review?(luke)
| Assignee | ||
Comment 3•8 years ago
|
||
Specifically:
- checkOverloaded -> rehashIfOverloaded
- checkUnderloaded -> shrinkIfUnderloaded
- checkOverRemoved -> rehashIfOverRemoved
Because I've always found that the `check` prefix doesn't clearly explain that
the table might be changed,
And:
- shouldCompressTable -> overRemoved
Because that matches `overloaded` and `underloaded`.
Attachment #8999827 -
Flags: review?(luke)
| Assignee | ||
Comment 4•8 years ago
|
||
I'm not sure about this one. This function is only called after rekeying.
Attachment #8999828 -
Flags: review?(luke)
Updated•8 years ago
|
Attachment #8999825 -
Flags: review?(luke) → review+
Comment 5•8 years ago
|
||
Comment on attachment 8999826 [details] [diff] [review]
Rename HashTable::findFreeEntry() as findNonLiveEntry()
Review of attachment 8999826 [details] [diff] [review]:
-----------------------------------------------------------------
Agreed, much better name.
Attachment #8999826 -
Flags: review?(luke) → review+
Comment 6•8 years ago
|
||
Comment on attachment 8999827 [details] [diff] [review]
Rename some HashTable methods
Review of attachment 8999827 [details] [diff] [review]:
-----------------------------------------------------------------
Good point! I have also found "check" to be a tempting verb to reach for initially, but ultimately ambiguous to everyone thereafter.
Attachment #8999827 -
Flags: review?(luke) → review+
Comment 7•8 years ago
|
||
Comment on attachment 8999828 [details] [diff] [review]
Rework HashTable::rehashIfOverRemoved()
Review of attachment 8999828 [details] [diff] [review]:
-----------------------------------------------------------------
::: mfbt/HashTable.h
@@ +1894,5 @@
>
> // Infallibly rehash the table if we are overloaded with removals.
> void rehashIfOverRemoved()
> {
> + if (overRemoved()) {
Good question, this obviously looks "wrong" given your renamings.
So the question is how overloaded() compares to overRemoved(). The big difference is that overloaded() takes into account (mEntryCount+mRemovedCount) whereas overRemoved() only takes into account mRemovedCount.
For the current (before this patch) only use case of overRemoved()/shouldCompressTable() in rehashIfOverloaded()/checkOverloaded(), the question is: if I'm going to rehash *anyway* (b/c overloaded()==true), should I grow or not. Rehashing sets mRemovedCount back to 0, so it makes sense that if a sufficient % of the table is removed, there's no need to grow given that overloaded(). IIUC, with shouldCompressTable() = 1/4 of table is removed, and overloaded() = 3/4 of table is (removed+live), this is perfect: when we rehash it will leave us at 1/2 utilized.
But getting back to this method the question is: should we only rehash based on mRemovedCount or also mEntryCount? My feeling is we need to take into account mEntryCount: otherwise we could have a table that is 3/4 full of live stuff, then we rekey a bunch leaving almost-but-not-quite 1/4 removed, and now we're near 100% full! So maybe this method should be killed and rehashIfOverloaded() used instead.
(Also maybe overRemoved() should be removed and inlined into its one caller.)
Comment 8•8 years ago
|
||
Comment on attachment 8999828 [details] [diff] [review]
Rework HashTable::rehashIfOverRemoved()
(Clearing; feel free to re-request if I misunderstood.)
Attachment #8999828 -
Flags: review?(luke)
| Assignee | ||
Updated•8 years ago
|
Attachment #8999828 -
Attachment is obsolete: true
| Assignee | ||
Comment 10•8 years ago
|
||
Attachment #9000135 -
Flags: review?(luke)
| Assignee | ||
Comment 11•8 years ago
|
||
Attachment #9000136 -
Flags: review?(luke)
Updated•8 years ago
|
Attachment #9000134 -
Flags: review?(luke) → review+
Updated•8 years ago
|
Attachment #9000135 -
Flags: review?(luke) → review+
Updated•8 years ago
|
Attachment #9000136 -
Flags: review?(luke) → review+
| Assignee | ||
Comment 12•8 years ago
|
||
Luke, what do you think about this?
Attachment #9001431 -
Flags: review?(luke)
Updated•8 years ago
|
Attachment #9001431 -
Flags: review?(luke) → review+
Comment 13•8 years ago
|
||
Pushed by nnethercote@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e483b91eafbc
Remove HashTable::maybeCreateTable. r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/f1e1cf1d42ec
Rename HashTable::findFreeEntry() as findNonLiveEntry(). r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/43e351bda401
Rename some HashTable methods. r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/2d9e3360e858
Rename HashTable::rehashIfOverRemoved(). r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/a3bf3a494b0b
Inline and remove HashTable::overRemoved(). r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/ca2edc3b4c1a
Merge HashTable::wouldBeUnderloaded() into underloaded(). r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/da46bfc2c089
Inline and remove HashTable::{over,under}loaded(). r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/17896e16e10b
Trivial comment fixes. r=me
Comment 14•8 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/e483b91eafbc
https://hg.mozilla.org/mozilla-central/rev/f1e1cf1d42ec
https://hg.mozilla.org/mozilla-central/rev/43e351bda401
https://hg.mozilla.org/mozilla-central/rev/2d9e3360e858
https://hg.mozilla.org/mozilla-central/rev/a3bf3a494b0b
https://hg.mozilla.org/mozilla-central/rev/ca2edc3b4c1a
https://hg.mozilla.org/mozilla-central/rev/da46bfc2c089
https://hg.mozilla.org/mozilla-central/rev/17896e16e10b
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox63:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in
before you can comment on or make changes to this bug.
Description
•