Closed
Bug 826951
Opened 13 years ago
Closed 13 years ago
JS::HashTable does not compact enough if most of its elements are removed by an Enum
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla21
People
(Reporter: justin.lebar+bug, Assigned: justin.lebar+bug)
Details
Attachments
(1 file, 1 obsolete file)
|
3.19 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
In ~Enum(), we call checkUnderloaded(). As I understand it, this compacts the table by half if it's underloaded.
But what if we removed more than half of the table's elements during the Enum()? Shouldn't we compact more, in this case?
I ran into this in bug 826515; there, we may well delete a large portion of a large (tens of mb) hashtable in one go.
| Assignee | ||
Comment 1•13 years ago
|
||
| Assignee | ||
Comment 2•13 years ago
|
||
I picked a bad base rev for that last push, but I think it was basically fine aside from the known failures. I pushed again to be sure. https://tbpl.mozilla.org/?tree=Try&rev=38fadb1f935c
| Assignee | ||
Comment 3•13 years ago
|
||
I think we could be more efficient with how we calculate the new size, but it's not simple, and I'm not sure it's worth worrying about. What do you think?
Attachment #698643 -
Flags: review?(luke)
| Assignee | ||
Updated•13 years ago
|
Assignee: general → justin.lebar+bug
Comment 4•13 years ago
|
||
Great find!
Could you factor out the underloaded computation (capacity > sMinSize && entryCount < ((sMinAlphaFrac * capacity) >> 8)) between underloaded() and compactIfUnderloaded() into a static function?
| Assignee | ||
Comment 5•13 years ago
|
||
Attachment #698643 -
Attachment is obsolete: true
Attachment #698643 -
Flags: review?(luke)
Attachment #698940 -
Flags: review?(luke)
Comment 6•13 years ago
|
||
Comment on attachment 698940 [details] [diff] [review]
Patch, v2
Review of attachment 698940 [details] [diff] [review]:
-----------------------------------------------------------------
Very nice
::: js/public/HashTable.h
@@ +956,5 @@
> + // Would the table be underloaded if it had the given capacity and entryCount?
> + static bool wouldBeUnderloaded(uint32_t capacity, uint32_t entryCount)
> + {
> + return capacity > sMinSize &&
> + entryCount <= ((sMinAlphaFrac * capacity) >> 8);
We've extended the column limit to 99, so this can all be on one line.
Attachment #698940 -
Flags: review?(luke) → review+
| Assignee | ||
Comment 7•13 years ago
|
||
I noticed that the comment on compactIfUnderloaded was out of date. I changed it to:
// Resize the table down to the largest capacity which doesn't underload the
// table.
| Assignee | ||
Comment 8•13 years ago
|
||
Comment 9•13 years ago
|
||
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
You need to log in
before you can comment on or make changes to this bug.
Description
•