Closed Bug 1824655 Opened 2 years ago Closed 1 years ago

Investigate skipping locking for the DOM jemalloc arena

Categories

(Core :: Memory Allocator, task, P2)

task

Tracking

()

RESOLVED FIXED
116 Branch
Tracking Status
firefox116 --- fixed

People

(Reporter: pbone, Assigned: pbone)

References

Details

(Whiteboard: [sp3])

Attachments

(1 file)

Smaug suggested we could disable locking for the jemalloc arenas created by DOMArena since they're only ever accessed from the main thread.

I tried it and found that it hasn't changed a whole lot for most tests. Indeed in speedometer it'd be a tiny fraction of the total runtime that we spend acquiring the lock.

https://treeherder.mozilla.org/perfherder/compare?originalProject=try&originalRevision=0a87812741f757733c11a01766326cce5d014012&newProject=try&newRevision=c658aacc240983073c3838e29a6d5a27068bf585&framework=13&page=1&showOnlyConfident=1

I had another test that timed how long it takes to get a lock and was showing >20ns for these completely uncontested locks. It turns out that that's roughly the time recorded for two consecutive clock_gettime(CLOCK_MONOTONIC_RAW, &time) calls on Linux (which I assume use the TSC). So the uncontested locks are definitly fast enough, at least for Pthreads on Linux.

I'm filing this bug to record these results in case anyone is curious in the future, not because it's code I actually want to land. I'll add a patch with the code I tested.

Assignee: nobody → pbone
Status: NEW → ASSIGNED
Whiteboard: [sp3]
Severity: -- → S3
Priority: -- → P2

Hmm, no changes on Windows. But some subtests on linux still like this quite a bit.

Maybe the locks we use on Windows are just faster anyway?

So with making these main-thread-only arenas, there are some parts of our code that call jemalloc_stats from off-thread. It can't read the stats from the arenas safely so I'm working on a fix for that.

Depends on: 1831852
Pushed by pbone@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/35d7297c823c Avoid locking for the DOMArena jemalloc arena r=smaug
Status: ASSIGNED → RESOLVED
Closed: 1 years ago
Resolution: --- → FIXED
Target Milestone: --- → 116 Branch
Regressions: 1839596
Blocks: 1839790
See Also: → 1843932
Regressions: 1875768
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: