Markers and their payloads are stored outside of the ProfileBuffer:
- They are allocated on the heap,
- They are initially attached to a list in thread local storage (TLS),
- They are moved to a list in ProfileBuffer during sampling, and a marker entry is added to the ProfileBuffer buffer,
- They need to be deleted if the ProfileBuffer entry has lapsed.
We should store markers and their payloads directly into the main ProfileBuffer buffer:
1 -> We would avoid external mallocs (using extra memory and CPU resources).
2 -> No need to manage markers in TLS memory.
3 -> No need to manage markers linked list in ProfileBuffer, and during sampling.
4 -> No need to manage marker lifetimes, their data would just get overwritten.
See details in bug 1549572 comment #6 about the proposed data structure.
This should also help separate marker storage from sampling needed for bug 1549482.