trace-server: move Span's derived half into lazy-allocated side arrays
tl;dr size_of::<Span>() 328 -> 192 Not pre-computing things also improves ingestion speed: 269->280MB/s Five per-span values are pure functions of the trace. They can be computed on demand and discarded on invalidation. * end * total_time * corrected_self_time * corrected_total_time * subtree totals bundle By preallocating these, we add 112 bytes to every span regardless of whether they're requested. `max_depth` moved to an AtomicU8 with a sentinel value for "not set" `extra` moves to a locked hashmap of boxes. `SpanRef::extra()` still retrusn a SpanExtra ref. The box it points to won't move while it's stored in the map. The timestamps move out, and are allocated on first touch. Slots are AtomicU64s rather than OnceLocks; we don't need a mutex because the value is the result of a pure function. In the rare case two threads race, they'll still end up with the same result. The `MEMORY_REPORT=warm` env var can force every derived value to be derived before reporting. This is less about performance of the server, and more to be able to estimate the peak allocation when the client is actually requesting data.
Showing
Please
register
or
sign in
to comment