[meta] Share more data between threads
Our profiles currently contain the following pieces of information which are shared between threads:
-
categories -
extensions -
pages -
counters -
libs(as of #3906)
And for each thread, we have the following pieces of information per thread:
-
resourceTable -
stringTable -
nativeSymbols -
funcTable -
frameTable -
stackTable - actual per-thread data, such as thread names, start / end times, samples, and allocations
We should move more of these per-thread tables into the shared part of the profile. This will reduce duplication, leading to smaller profile upload sizes and smaller in-memory sizes. It should also simplify some of the code involved in merging or diffing threads, though most of the merging logic will still exist for profile processing and for profile merging.
Furthermore, having function IDs which are consistent between threads will make it easier to switch between multi-thread views and single-thread views without losing your place. For example, it would make it easier to apply call tree transforms to multiple threads at the same time, without losing them when switching back to the single-thread view.
┆Issue is synchronized with this Jira Task
I think it's a good idea to merge these. There is one thing to keep in mind that, we have some fast checks in our codebase that bails early for per-thread structures if stringTable contains something etc.
For example, for checking if we have any screenshot in a thread, we are using stringTable.hasString('CompositorScreenshot'):
https://github.com/firefox-devtools/profiler/blob/7e0be227b7a0aeb5935778af89e1c11be657ccdc/src/profile-logic/tracks.js#L369-L385
We have a few more checks like this. If we merge all the string tables into one, these checks are going to become more costly since we'll have to iterate them all the time (or we can optimize this by doing these checks only once during the initial load and saving them somewhere.)