Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upInvestigate SpiderMonkey GC rooting performance #2334
Comments
|
To clarify, SpiderMonkey internally uses the types in http://mxr.mozilla.org/mozilla-central/source/js/public/RootingAPI.h such as |
|
We can do this without modifying SpiderMonkey, by rooting just our data structure and teaching SpiderMonkey how to trace it. This is what Gecko does for dictionaries. See also the existing |
|
SpiderMonkey provides a CustomAutoRooter/AutoGCRooter API which allows custom tracing behaviour. |
|
Is this still relevant, given that we have similar looking types in js.rs? |
|
Yep. We're still doing the same rooting strategy as SpiderMonkey (ie. linked lists). |
Servo will do a lot more rooting and unrooting than Gecko, because we have a JS-managed DOM. This is especially the case once we stop using the conservative stack scanner.
SpiderMonkey stores roots in a linked list. We only pop from the end of this list, but it's still the case that linked lists are pretty inefficient in terms of allocations and cache line packing. We should measure the performance and try alternative data structures. A dynamic array (i.e. vector) might work well.
This needs to be compatible with the public SpiderMonkey API, which might mean teaching SpiderMonkey to look in two places for roots — the linked list, and the new data structure. When one of the two is empty (and represented by a NULL pointer) this should have minimal overhead.