Off-thread parsing currently results in complexities around GC interactions.
Currently we do the following steps for off-thread parsing:
- Create a new gc::Zone, Compartment, and Realm/Global
- Use AutoKeepAutos to prevent main-thread from starting any GC in AtomsZone
- Do the parse
- Create GC things in our Realm as we go
- Object literals (including their Shape)
- Atomize property-names and string-literals as we go,
taking global locks in the AtomZone as needed.
- Perform 'mergeRealms' step to munge the temporary Zone into the target
zone, performing minor updates on gc-things as we transfer ownership.
There is also a lot of hard to follow code around these GC-things as the are incrementally constructed across various parts of parser and frequently used in partially initialized states.
We are starting to see more examples of real-world perf impact by the off-thread parse getting conflicting with main-thread such as Bug 1543776 and atom lock contention that sometimes shows up.
In this bug I'd like for us to look at what the minimal requirements would be to fix in our existing parser. This would involving atomizing private to the parser (in the off-thread case), and replacing the ObjectBox design.