Closed
Bug 1543055
Opened 6 years ago
Closed 6 years ago
AllocationSiteKey hashing can cause quadratic behavior
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla68
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: jandem, Assigned: jandem)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
The testcase below runs in 42 ms. Now if you change |var x = i| to |var x = 0|, we hit a terrible perf cliff and it takes > 6700 ms.
What's happening is that AllocationSiteKey::hash uses the bytecode pc but AllocationSiteKey::match uses script + offset. This breaks down when a ton of scripts use the same underlying bytecode because they'll all have the same hash.
Noticed this while looking into bug 1542995.
function test() {
var arr = [];
for (var i = 0; i < 50000; i++) {
var x = i;
var f = Function("return [Math, " + x + "]");
arr.push(f);
}
var t = new Date;
for (var i = 0; i < arr.length; i++) {
arr[i]();
}
print(new Date - t);
}
test();
Assignee | ||
Updated•6 years ago
|
Type: task → defect
Assignee | ||
Comment 1•6 years ago
|
||
This also uses HashGeneric/AddToHash instead of manual XOR'ing.
Comment 2•6 years ago
|
||
As suggested on IRC, it might make sense to give every script a unique ID if this operation is common, and save adding/looking one up in the unique ID hash table.
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/21ee37c5b888
Fix AllocationSiteKey hashing to not have quadratic behavior when many scripts share bytecode. r=jonco
Comment 4•6 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
status-firefox68:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in
before you can comment on or make changes to this bug.
Description
•