Closed Bug 1052248 Opened 5 years ago Closed 5 years ago

Tweak the goodAllocated heuristics

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla34

People

(Reporter: njn, Assigned: njn)

Details

Attachments

(1 file)

Apologies for the churn in this code, but I came up with a simpler and better
formulation of the exceptional cases in goodAllocated(): if the usual
|goodCapacity| computation gives us a capacity that is 2/3 or more of the length,
we should just increase |goodCapacity| to length.

This requires only one special case in goodAllocated(), instead of two. Also,
for arrays with more than |EagerAllocationMaxLength| elements that get resized
up to their final value, the old code would only right-size them if their
length was very close to a power-of-two, whereas the new code will do it for
any length.

E.g. for length=10000, the old code would resize via the following capacities:
6, 14, 30, ..., 4094, 8190, 16382. The new code does 6, 14, 30, ..., 4094,
10000.
Attachment #8471319 - Flags: review?(bhackett1024)
Attachment #8471319 - Flags: review?(bhackett1024) → review+
https://hg.mozilla.org/mozilla-central/rev/e9ae7410d687
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in before you can comment on or make changes to this bug.