Repository navigation
Conversation
zzylol
added a commit
that referenced
this pull request
Nov 26, 2026
git mv only, so history follows each file; the next commit makes the crates build.
The ingest shards, the ingest coordinator, the precompute pool and the committer move to precompute::engine; the query-N workers to query::workers; the persist-N threads to storage::persist_pool. The data plane's engine keeps EngineOptions, install and EngineHandle, which wires the two engines to one published store.
- MAX_TIME_MS moves to common: ingestion and the Prometheus parameter parser (an adapter from step 6) both bound times by it. - PrecomputeOptions documents its fields instead of pointing at the data plane's EngineOptions. - Ingestion::newest_sample_ms and Precompute::refresh had no callers and are deleted. - README's layout table and the design documents' path notes name the new crates; two comments name the moved files.
Items used only inside their crate since the split are pub(crate), so the compiler keeps the boundary the split set up: - precompute: the push pipeline's types (Morsel, Feed, PushStore, PushGroup, Partial, PushShard, probe), the refresh task graph, and the Ingestion and Precompute methods only the engine calls (clock, watermark, close, maintain, push_run, missing_only, tasks, the group accessors). - storage: ViewFiles::sync_if_due and delete_expired, now that the persist-N threads are storage's.
zzylol
force-pushed
the
refactor/layout-common
branch
from
November 28, 2026 00:56
3f39078 to
d784733
Compare
zzylol
force-pushed
the
refactor/layout-engines
branch
from
November 28, 2026 00:56
9e99e2e to
02d480a
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.
Summary
crates/data-planestill holds the ingest side, the query side andengine.rs(about 2,700 lines), which runs both. Nothing stops the query code from reaching into the ingest threads, and the next step (thecommontraits wired at the seams) has no crate boundary to put them on.docs/design/repo-layout.md(docs(design): repository layout and engine boundaries #874). Two new crates,precomputeandquery, takeingestion.rs/push.rsandquery.rs/result_cache.rs.engine.rssplits: the ingest shards, theingestcoordinator, the precompute pool and the committer go toprecompute::engine; thequery-Nworkers toquery::workers; thepersist-Nthreads tostorage::persist_pool.data-planekeepsEngineOptions,installandEngineHandle, which wires the two engines to one published store.sum by (job) (sum_over_time(data[10s]))) gives byte-identical HTTP responses and the same/metricslines before and after (see Verification). For example,cargo run --release -p data_plane --example ingest_bench -- 10000 120 views 1 persiststill works;IngestionOptionsnow comes fromprecompute::ingestion.Review guide
refactor/layout-common(feat(common): engine boundary types and the fallback trait (layout step 4) #878). This is a stacked draft; feat: engines as concrete types; PlanInstaller and QueryDispatcher (layout step 5b) #880 (traits,PlanInstaller,QueryDispatcher) is stacked on it.git mvonly (ingestion.rs,push.rs→crates/precompute/src/,query.rs→crates/query/src/lib.rs,result_cache.rs→crates/query/src/), so history follows each file.engine.rsand the crates' manifests. Import paths in tests and benchmarks.crates/precompute/src/engine.rsfrompub struct Sharedto the end ofInstalledPrecompute::start(namedPrecomputeEngine::starthere),crates/storage/src/persist_pool.rs,crates/query/src/workers.rs, andcrates/data-plane/src/engine.rs.precompute::enginefromfn flushto the end ofWindowTasksis moved unchanged except the two persist call sites (persist.queue(…)withoutshared,persist.barrier(closure)).serve_persistis moved unchanged except that it takes the backlog andMetricsinstead ofShared. Import paths incrates/data-plane/tests/andbenchmarks/micro/.Old → new
crates/data-plane/src/…)ingestion.rs,push.rscrates/precompute/src/(packageprecompute), modulesingestionandpushquery.rscrates/query/src/lib.rs(packagequery)result_cache.rscrates/query/src/result_cache.rsengine.rs:PrecomputeMode,SlowRefresh,IngestError,Command,ShardMessage,PrecomputeJob,Shared,RunningGuard,try_ingest,advance_watermark,stop,hold_precompute, the stats getters,admit_shards,admit,flush,serve_shard,serve_ingest,queue_refreshes, the precompute pool (spawn_precompute,Slots,compute_window,TaskInputs,serve_precompute,commit_window,WindowTasks) and the spawning half ofEngineHandle::spawncrates/precompute/src/engine.rs:PrecomputeEngine::startand its methodsengine.rs:QueryJob,spawn_query_workers,EngineHandle::{evaluate, evaluate_range_step, snapshot, cached, run_on_worker}crates/query/src/workers.rs:QueryWorkersengine.rs:PersistJob,PersistBarrier,PersistPool,release_persist_queue,serve_persist;Shared::{persist_backlog, persist_queue}crates/storage/src/persist_pool.rs:PersistPool,PersistBacklog,PersistOptionsengine.rs:EngineOptions,DEFAULT_VIEW_CACHE_IDLE_MS,install,view_tier,EngineHandlecrates/data-plane/src/engine.rsprometheus::MAX_TIME_MScommon::MAX_TIME_MSengine.rstests (admission,windows_commit_in_window_order…,running_guard_clears_on_panic, …)crates/precompute/src/engine.rstests, same module pathengine::tests::…Dependency graph
precomputeandquerydo not depend on each other. Both depend onstorage: see Decisions.Behavior: before → after
No change. The threads are the same (
ingest-N,ingest,precompute-partials,precompute-queue,precompute-N,precompute,persist-N,view-cache,query-N), spawned in the same order. The CLI flags, defaults,/metricslines, HTTP responses and view-file names are the same.Interfaces
crates/precompute/src/engine.rs(new; former parts ofdata_plane::engine)crates/storage/src/persist_pool.rs(new; formerPersistPool/serve_persistofdata_plane::engine)crates/query/src/workers.rs(new; former query half ofdata_plane::engine)crates/data-plane/src/engine.rs,crates/data-plane/src/lib.rsIngestion::newispubbecausedata_plane::engine::installcompiles the ingestion and the queries together (as before), and calls it from another crate now.Usage (unchanged for callers):
DataPlane::with_options(plan_json, prometheus_url, EngineOptions { ingest_threads: 4, ..EngineOptions::default() })runsinstall(query compile,--no-forwardcheck,Ingestion::new), thenPrecomputeEngine::start(shards, coordinator, persist threads, view-cache monitor, precompute pool; it publishes the initial raw data and views) andQueryWorkers::start(query-N), both on oneArc<PublishedStore>.POST /api/v1/write→EngineHandle::try_ingest→PrecomputeEngine::try_ingest;GET /api/v1/query→EngineHandle::{cached, evaluate}→QueryWorkers.Algorithm changes
None.
Decisions and open questions
Needs reviewer decision: none.
Decided (judgment calls in this PR):
precompute → storageandquery → storage. The design says the three crates do not depend on each other and meet incommon's traits. Both engines needstorage's concrete stores: queries read one copy-on-write snapshot of the raw data and views (PublishedStore), and runs read the executor's batches throughRunStore, itsDataStore. By the design's rule ("concrete types they must share go in common or in the lower crate"), they stay instorage, the lower crate;commonhas no store trait (repo-layout decision 4). There is no edge betweenprecomputeandquery, and no cycle.storagewith a small interface for the backlog accounting (refactor: split internal-metrics and storage crates out of data-plane (layout step 3) #877 deferred them):PersistBacklog(windows and bytes queued, read by/metrics) is shared by the pool and the engine;PersistPool::barriertakes a closure instead of the committer'soneshot::Sender, sostorageneeds notokio. One boxed closure per event-time barrier.view_tier()stays indata-plane. It readsEngineOptions(the result cache's and query-time results' bytes, the view cache options).data-planebuilds the tier and passes it inPersistedViews.PrecomputeOptionsis a subset ofEngineOptions, built byEngineOptions::precompute().EngineOptionsstays flat, so the tests that set options (EngineOptions { ingest_threads: 4, ..EngineOptions::default() }) and the CLI do not change.MAX_TIME_MSmoves tocommon. Ingestion drops samples beyond it, and the Prometheus parameter parser refuses times beyond it; the parser becomes an adapter in step 6, which depends oncommononly.Metricsis anArc, shared by the precompute engine, the persist threads and the query workers. One more pointer hop per recorded phase (per batch or window, never per sample).Verification
One remote host per tree, one target directory each,
ulimit -nraised (as in #876).cargo fmt --all -- --checkcargo build --workspace --all-targets --locked(all 8 micro benchmarks included)cargo clippy --workspace --all-targets --locked -- -D warningscargo test --workspace --lockedforward_mode::bodies_wait_for_a_raw_store_that_is_downandplanner_executor_parity::push_precompute_stores_the_window_paths_view_rowsfailed once under load, timing-dependent, and passed alone, 3/3 and 1/1)The four new suites are
precompute's andquery's unit tests and doc tests. The sorted lists of passing test names (test … ok) are identical to #878's head (no new test): theengine::tests::…tests keep their names inprecompute, and the moved modules keep theirs (result_cache::tests::…).End to end, an uncommitted test (
tests/zz_parity_dump.rs, run on both trees) writes 60 s of 3 series to a data plane planned forsum by (job) (sum_over_time(data[10s])), sets the barrier at 60 s, and records the status, headers and body of: two instant queries (one with surrounding spaces), a range query twice (the second from the result cache), a query at a window not yet stored, a range reaching one, and an unplanned query, each with--no-forwardand with forwarding; then every/metricsfamily, metric name and label set. The two outputs are byte-identical (547 lines).Micro benchmarks on the same quiet host (16 cores pinned), three runs each:
ingest_bench 10000 120 views 1 persist: every write acknowledgedview_read_bench 10000 40 15(KLL): pread cold / warm, ns per rowAll within run-to-run noise (one run in three of each tree refreshes about 2.5 s later, the same on all three).
An independent review covered correctness and behavior parity, over-abstraction and dependency direction, dead code and duplication, and hot-path efficiency. Its findings for this PR are fixed in the third commit:
MAX_TIME_MSmoved tocommon(above).PrecomputeOptionsdocuments its own fields instead of pointing atEngineOptions, which is in a crate above it.Ingestion::newest_sample_msandPrecompute::refreshhad no callers and are deleted.Whole-stack review fixes
pub(crate)for items used only inside their crate since the split: precompute's push pipeline types (Morsel,Feed,PushStore,PushGroup,Partial,PushShard,probe),RefreshTaskGraph, and theIngestion/Precomputemethods only the engine calls (set_push_groups,group_windows,group_metrics,refreshed_through,queries_read_raw_data,advance_clock,advance_newest_sample,close,advance_watermark_at,maintain,push_run,missing_only,tasks); storage'sViewFiles::{sync_if_due, delete_expired}, now that the persist threads are storage's.crates/common/row says "types and theFallbackClienttrait".Follow-ups
PlanInstaller,QueryDispatcher.precompute → storage,query → storageandMAX_TIME_MSincommon.