Repository navigation
Compare sketch, exact and store-and-query in the top-k demo as traffic grows - #40
Merged
Merged
Conversation
zzylol
force-pushed
the
feat/pipeline-throughput
branch
from
October 20, 2026 23:24
86fd69c to
69e0727
Compare
zzylol
force-pushed
the
feat/topk-tradeoff-demo
branch
from
October 20, 2026 23:24
89aecbf to
70db4c0
Compare
zzylol
force-pushed
the
feat/topk-tradeoff-demo
branch
from
October 20, 2026 23:38
70db4c0 to
f4c1d28
Compare
zzylol
force-pushed
the
feat/pipeline-throughput
branch
2 times, most recently
from
October 20, 2026 23:38
f5ba2ad to
edad787
Compare
zzylol
force-pushed
the
feat/topk-tradeoff-demo
branch
from
October 20, 2026 23:38
f4c1d28 to
21506c7
Compare
The top-k demo now shows the trade-off between computing in front of the store and storing everything to query later, as the traffic grows. - Store and query: the raw path is one stage per source (raw-sink-a/b, 4 requests in flight to loki-raw); a query job runs the LogQL top-20 over loki-raw once per window and reports that answer and its heavy-hitter accuracy against exact. - Freshness breakdown: merges and detectors report when they received and emitted each window (asap_stage_received/emitted); the query job times each approach's backend query (asap_query_seconds). - Whole-system cost: Prometheus scrapes loki-raw, itself and the query job, so CPU and memory are shown per component and per approach. - Traffic over time: the scenario generator takes rate and cardinality changes; the top-k scenario doubles the rate every 5 minutes (5k to 80k points/s per source) and grows routes from 100k to 1M. - Acceptance checks the answers at the starting rate, the timing gauges and the store-and-query answer.
One table joins the latest window's top-10 of sketch, exact and store and query by route, with each approach's rank, count and error against exact.
The sketch and exact merges waited the full 5 s grace after every window, so the sketch's freshness was a constant 5.9 s although both sources' sketches arrive about 10 ms after the window ends. With sources: 2, a merge emits a window once both sources' messages carried it (each source sends a window in one message, in window order); the grace stays as the timeout for a missing source. The raw sink likewise reports a window once its source has sent a later point and the store acknowledged every message of the window, instead of waiting the grace.
CPU, memory and bits per second into each stage now get one panel per approach, each with its components and the approach's total, and Prometheus, shared by all three, its own panels. The per-window count of the new route is removed; the comparison table shows it.
A demo left at the top rate stored every raw point in loki-raw's container layer until the host's disk was full (about 50 GB in 15 hours). Only the latest windows are queried, so retention deletes points older than 2 hours.
…wered Merges count a window's messages, not distinct sources; the limit is documented and inputs that arrive after their window was emitted are logged. When raw-sink reports a window at its 50 s timeout with points still waiting for the store, it reports how many (asap.raw.unacknowledged) and the time of the report as the delay, and the query job flags the window (asap_raw_incomplete). The query job escapes label values, experiments.py reads only the sketch's heavy-hitter accuracy, and the top-k breakdown says the merge waits for both sources.
zzylol
force-pushed
the
feat/topk-tradeoff-demo
branch
from
October 20, 2026 23:39
21506c7 to
0fdc065
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The top-k demo compared the sketch with exact computation, but not with the obvious alternative: store every raw point and query the store when the answer is needed. Computing in front of the store keeps much less data but drops the raw points; storing everything costs ingestion, storage, query CPU and freshness. The demo also ran at one fixed rate, so it could not show how each approach scales, and it reported one completion delay per pipeline without saying where the time goes. That delay was dominated by the merges, which always waited a 5 s grace after every window although both sources' sketches arrive within about 10 ms.
What
The top-k dashboard (
/d/asap-topk) now compares three approaches on identical input while the traffic grows:method="raw"): one stage per source (raw-sink-a/b) writes every point toloki-raw. A query job runs a LogQL top-20 overloki-rawonce per window, then reports that answer and its heavy-hitter precision, recall, F1 and ARE against exact.loki-raw, LogQL query.loki-rawand the query job; Prometheus, shared by all three, has its own panels./new/hot-routetakes 15% of traffic at minute 10, and routes grow from 100,000 to 1,000,000 at minute 15. Throughput and distinct routes per window are plotted.How
scenario_generator: takes{after_seconds, signals_per_second}and{after_seconds, attribute, cardinality}changes. Batches per second are fixed by the highest rate, and each second's points are spread over them. A batch still depends only on its second and index.window_merge,exact_merge):sources: 2. Each source sends a window in one message, in window order, so a window is complete once two messages carried it; otherwise the grace still applies.asap.stage.received/asap.stage.emittedgauges (seconds after the window end, labelledmethodandstage). Detectors add their own timing and pass the merge's on to Prometheus.raw_sink:loki-rawacknowledged every message of the window (the grace applies if the source idles).asap.raw.unacknowledgedand that time as the delay. The query job flags such windows withasap_raw_incomplete.labels(heresource) and sends to Loki with 4 requests in flight.raw-branch-a/bandraw-mergeare removed.query_job.py(stdlib Python, its own pinned container):asap_compare_topk), so the table compares one window although store and query answers later.hh-accuracygauges are labelledmethod="sketch";experiments.pyreads only those.loki-raw, itself and the query job.loki-rawallows 5-minute queries and keeps 2 hours of points (compactor retention), so a long-running demo does not fill the disk.Before
After
Measured on the demo machine over the 30-minute ladder (2 sources, 1-minute windows):
Verification
cargo fmt --check,cargo clippy --all-targets --features otap-engine,stream-benchmark -- -D warningsandcargo test --features otap-engine,stream-benchmarkpass. New tests cover rate and cardinality changes, change validation, merge arrival time, stage timing, emitting once every source sent a window (and at the grace when one is missing), the raw sink reporting once its source moved past a window, and the 50 s timeout with unacknowledged points.acceptance.py --use-cases topkon the demo machine before the early-emit change: 11/11. CI runs the scaled acceptance on this head.experiments.pyreports the raw per-source stage asraw-sink-a/b. The experiment-results PR will redefine its pass-through baseline when it is rerun on this stack.