Consider force-aligning UTF16 strings in profile buffer
Categories
(Core :: Gecko Profiler, task, P3)
Tracking
()
People
(Reporter: mozbugz, Unassigned)
References
(Blocks 1 open bug)
Details
Thanks to bug 1663382, most strings that are in the profile buffer are used directly (through a Span) when generating the final JSON output.
Unfortunately this is not possible for 16-bit strings that are starting at an odd address, because these need to be converted to UFT8, and the conversion code requires proper alignment.
To help with this, during profiling 16-bit strings could be copied into the profile buffer with the proper alignment.
Note that we don't want to run the 16-to-8 conversion at that time (which would solve this issue), to keep the profiler overhead low.
Tech details:
We need to compute the buffer entry size before we know where it will be located, so it's not possible to add 1 byte in only the cases of 16-bit strings that would end up non-aligned.
So instead, we'll need to always add 1 byte to all 16-bit strings, and then when copying them into the buffer, we can make sure the copy is correctly aligned. When deserializing, we can then read at the next aligned location if necessary.
I think this extra byte, and the bit of code to handle aligning addresses, are an acceptable cost with a small impact, compared to the memory and CPU costs of having to copy the strings out of the buffer and into temporary heap-allocated buffers when not aligned.
Low-priority, because a quick survey indicated that these 16-bit strings are currently fairly rare, less that 1% of 8-bit strings! Of course this could possibly change if we add more UTF16 strings.
Description
•