enhancement: batch span-only metrics evaluation - #7711
Conversation
Signed commits reportAll 2 commits between |
|
|
a6a0595 to
2659e81
Compare
|
Hi thanks for trying this out. It's interesting that this was picked up, I was very sad having to add that mutex because it was known to be causing ~10% performance hit but also necessary for the live stores since they try to operate on everything concurrently. The benchmarks above look nice, but I'm hesitant to go with this approach for a few reasons:
Other ideas This PR makes me realize that we don't need the mutex for backend querying at all, since it's always a single block per job in separate evaluators. Thanks, this would make a very nice separate PR, to add it as an option to the compile function like WithNoLock(). Regarding live store contention, I'm guessing from the PR that you're seeing a lot of contention issues with WAL blocks? The default flush settings generally minimize this, i.e. only the last 30/60s is in the form of a WAL block. Have you customized any settings or have anything unique to your environment? I've been thinking the issue is that we are trying to run every span from every block through an evaluator. The batching is a way to share it faster, but if we take a step back the real issue is that it actually doesn't need to be the same evaluator. For local on-disk caching we already evaluate each block separately, and maybe there is a way to do the WAL block flushes the same way. It's possible that there is a way we can still do batching without pooling. What if we allocated a slice of |
What this PR does:
Batches uncapped span-only TraceQL metrics evaluation in groups of up to 64 spans so concurrent WAL-block workers acquire the shared evaluator mutex once per batch instead of once per span.
Storage iteration and
SecondPasscallbacks remain outside the aggregation lock. Batch-owned span state is released after aggregation, and reusable array-valued attributes are snapshot-cloned before that lock is acquired. Queries withMaxSeriesintentionally retain per-span iterator advancement so they stop storage at the exact cutoff rather than prefetching a batch past it.This reduces lock handoff pressure for concurrent WAL-backed range queries while bounding retained iterator state.
Which issue(s) this PR fixes:
None.
Testing:
Added coverage for batch behavior, result equivalence, watchers, exemplars, array attributes, cancellation, max-series handling, iterator fallbacks, and WAL batch propagation. The validation scope also includes focused TraceQL and vParquet5 race tests, livestore and querier tests, the contention benchmark under the race detector, vet, and changelog validation.
Workload:
uncapped span-only QueryRange across 10 concurrent WAL blocksns/opWorkload:
uncapped span-only QueryRange CPU and evaluator contention profiles across 10 WAL blocksevaluator-mutex-delay-ns/opevaluator-block-delay-ns/opAI assistance:
An AI coding assistant was used to inspect the existing batching path, prepare the implementation, and run focused validation.
Checklist
.chloggen/Authored and verified by Perfloop: every claim above was co-measured on both trees and independently re-verified before submission — the full record is public: case_wqf5vvek76. Replies from this account are human-approved, and a human operator is accountable for this contribution.