Closed Bug 1473414 Opened 6 years ago Closed 6 years ago

Use special-purpose allocator for CallbackNode objects

Categories

(Core :: Preferences: Backend, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: kmag, Assigned: kmag)

References

(Blocks 1 open bug)

Details

(Whiteboard: [overhead:15K])

We allocate thousands of CallbackNode objects in every process, and the number of live objects doesn't go down much.

Prior to bug 1472523, the general-purpose allocator worked pretty well, since the 32 byte objects fit neatly into a jemalloc bucket size. But bug 1472523 increased the size to 40 bytes, which bumps them up to the 64 byte allocation size, and wastes 24 bytes per object. It's still a net win, but we can do better.

If we use an arena allocator and a free list for unused entries, wasted memory goes down considerably, and we save 10-15K per base content process.
For 40 bytes, it should be 48, not 64.
(In reply to Mike Hommey [:glandium] from comment #1)
> For 40 bytes, it should be 48, not 64.

I'll assume you're right. I did check the value MallocSizeOf reported, but that was a week or so ago, and I probably misremembered.

Either way, I did test this with a special-purpose allocator, and it did save a considerable amount of memory.
If it's only an extra 8 bytes, I think we're actually better off using that space for a Variant so we can support matching multiple preferences in the same callback when callers use RegisterCallbacks.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
(In reply to Nicholas Nethercote [:njn] from comment #4)
> My favourite comment in the entire codebase is this one:
> https://searchfox.org/mozilla-central/rev/
> 6ef785903fee6c0b16a1eab79d722373d940fd78/memory/build/mozjemalloc.cpp#53-88
> 
> :)

Handy.
You need to log in before you can comment on or make changes to this bug.