Closed Bug 1681003 Opened 5 years ago Closed 5 years ago

Figure out the root cause of bug 1671170

Categories

(Core :: Memory Allocator, task)

task

Tracking

()

RESOLVED FIXED
85 Branch
Tracking Status
firefox85 --- fixed

People

(Reporter: emilio, Assigned: emilio)

References

Details

Attachments

(1 file)

That is, the cause of https://github.com/servo/rust-smallvec/issues/243. I can confirm that:

So somehow the change from malloc + memcpy to realloc made it slower, which is unexpected. My guess is that something is holding on a global lock when it shouldn't in realloc, but that doesn't happen on malloc somehow...

The fact that it was a Windows + Linux regression, but not Mac, makes me suspect PHC is somehow involved (PHC is not enabled by default on Mac). This will eventually compare trunk vs. 1.5.1 with PHC disabled:

Flags: needinfo?(emilio)

Preliminary investigation does look like this is a PHC / jemalloc issue.

Component: CSS Parsing and Computation → Memory Allocator

So if I understand correctly, PageAlloc has a mechanism to avoid multiple threads racing for an allocation doing slow stuff like getting stack-traces by incrementing the delay, but that's not done by PageRealloc. And every time you realloc something that PHC allocated, we get a new stack using the global mutex...

Nope, so regression is still there with PHC disabled, and thus my patch does ~nothing and my hypothesis was wrong.

Ok, second hypothesis: RallocGrowLarge is slow.

Ok, here's a better theory. This call should actually switch arenas for larger allocations. Otherwise we grow the thread-local arenas a lot.

Depends on: 1681075
Assignee: nobody → emilio
Status: NEW → ASSIGNED
Attachment #9191634 - Attachment description: Bug 1681003 - When realloc() grows an allocation, switch arenas if malloc would've done that. r=glandium → Bug 1681003 - When realloc() grows an allocation, allow switching out of thread-local arenas if plain malloc() would've done that. r=glandium
Attachment #9191634 - Attachment description: Bug 1681003 - When realloc() grows an allocation, allow switching out of thread-local arenas if plain malloc() would've done that. r=glandium → Bug 1681003 - When realloc() grows an allocation, allow switching out of public arenas if plain malloc() would've done that. r=glandium
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ac54ee8d90e5 When realloc() grows an allocation, allow switching out of public arenas if plain malloc() would've done that. r=glandium
Blocks: 1632469
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: