Introduce a third kind of finalizer for JSObjects with trivial finalizers
Categories
(Core :: JavaScript: GC, enhancement, P2)
Tracking
()
People
(Reporter: jonco, Unassigned)
References
(Blocks 1 open bug)
Details
Currently we have two finalization kinds for objects, foreground and background. The former is for objects which have a class finalize hook set which requires being run on the main thread, and the latter for objects either with no class hook set or one which can run from a background thread.
This proposes adding a third class, for objects with no class hook and just having the internal finalizer. This would also apply to most other GC things with simple internal-only finalization and would be called a 'trivial' finalizer.
The benefit of this is that it allows us to start reusing arenas that have been swept and found to be empty much sooner. Currently we must wait until the end of finalization to reuse these since finalize hooks may rely on them still being present. This is because HeapPtr's destructor gets the zone from its target's arena header. Reusing the arena in a different zone or freeing it entirely would break this. HeapPtrs are relatively rare however and most objects are plain JS objects without a finalize hook.
The effect or reusing arenas sooner is to reduce the total amount of heap memory required for allocation heavy workloads. It may also reduce the amount of GC happening, as freeing arenas brings down the heap size and may prevent GC trigger threshold being reached.
Finally it will allow memory allocated with a custom slots/elements allocator (see bug 1911537) to be freed sooner and would also allow that to happen in parallel with subsequent finalization.
Updated•27 days ago
|
Description
•