Repository navigation
Conversation
This was referenced Nov 26, 2026
git mv only, so the history follows each file; the next commit makes the crates build.
Step 3 of docs/design/repo-layout.md. `internal_metrics` holds the measurement types (phase timers, latency histograms, the engine's `Metrics`); `storage` holds the raw and view stores, the window cache, the memory budget, segments, persistence, state codecs and the series interner, and the view-cache monitor thread's body from engine.rs. `data_plane` depends on both; `storage` depends on `internal_metrics` and `asap-executor`, never on `data_plane`. The `/metrics` renderer and its `Gauges` stay in data-plane (`metrics_endpoint.rs`) because they read ingestion, query and store state. The view tier moves from `Metrics` to `Gauges`. `millis` and `window_end` move to `storage::store`, the lower crate that uses them. The persist-N threads stay in engine.rs until step 5.
serve_view_cache sits in memory_budget next to what it calls, so monitored_target is private; Gauges and render are pub(crate); the internal_metrics crate doc says what it holds now.
…cs split - CI checks formatting with cargo fmt --all, so a new crate is checked too (the README and pre-commit already run it). - The /proc resident-memory reader moves to internal-metrics, next to the other /proc readers; libc is only a dev-dependency of data-plane (the benchmarks' posix_fadvise). - storage items used only inside storage are pub(crate): the segment format version and Segment's seal/end/forget helpers, the persisted view index, the state and text-key codecs, labels_of_identity, the window cache's get_or_load and evict_idle.
zzylol
force-pushed
the
refactor/layout-folder-moves
branch
from
November 28, 2026 00:56
7c0fce8 to
373e0a0
Compare
zzylol
force-pushed
the
refactor/layout-storage-crates
branch
from
November 28, 2026 00:56
5c7cf0f to
f93e5e7
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-planeis still one crate. Its stores, its on-disk view format and its self-measurements live next to the ingest, query and HTTP code. Nothing stops a store from reaching into the engine, or a measurement type from reaching into the stores.docs/design/repo-layout.md(docs(design): repository layout and engine boundaries #874). It adds two leaf crates,internal-metricsand thenstorage, and moves their files out ofdata-plane. Every caller imports from the new crates.storagedoes not depend ondata_plane./metricstext and test results. For example,cargo run --release -p data_plane --example tier_benchstill works;ViewReadnow comes fromstorage::persist.Review guide
refactor/layout-folder-moves(refactor: move folders to the layout in docs/design/repo-layout.md (layout step 2) #876). This is a stacked draft.git mvonly, so history follows each file. The second makes the crates build. The third adds the new packages to the CI format check. The fourth is the first review's fixes; the fifth the whole-stack review's (below).crates/storage/Cargo.toml,crates/internal-metrics/Cargo.toml,crates/data-plane/Cargo.toml,crates/data-plane/src/metrics_endpoint.rs, and theShared/render_metrics/serve_view_cachehunks ofengine.rs.crate::store→storage::store,crate::metrics→internal_metrics, …) indata-plane/src,data-plane/tests,benchmarks/micro.metrics.rs → metrics_endpoint.rsas the rename andinternal-metrics/src/lib.rsas a new file, because the larger half of the file stayed. In the first commit,metrics.rsis a pure rename tointernal-metrics/src/lib.rs.metrics_endpoint.rsis that file'sGauges,render,escape,resident_bytesand its render test, unchanged except as listed below.Old → new
crates/data-plane/…)src/metrics.rs:thread_cpu_ns,Timer,PhaseStats,Latency,WindowLatency,QueryMetrics,PushMetrics,Metrics,thread_cpu_secondscrates/internal-metrics/src/lib.rs(packageinternal_metrics)src/metrics.rs:Gauges,render,escapecrates/data-plane/src/metrics_endpoint.rs(private module)src/metrics.rs:resident_bytesinternal_metrics::resident_bytes(with the other/procreaders)src/{store,window_cache,memory_budget,segment,persist,state_codec}.rscrates/storage/src/(packagestorage);state_codecstays a private modulesrc/series_ids.rscrates/storage/src/series_ids.rs(see Decisions)ingestion::millis,ingestion::window_endstorage::store::millis,storage::store::window_endengine.rs:serve_view_cache(theview-cachethread's body)storage::memory_budget::serve_view_cacheMetrics::view_tierGauges::view_tier, held by the engine'sShared::view_tiertests/view_cache_charge.rs,tests/series_ids.rscrates/storage/tests/metrics::tests::records_and_renders_phasesinternal_metrics::tests::a_phase_records_its_thread_cpu; the render assertions stay inmetrics_endpoint::tests::renders_phases_and_queriesDependency graph
storagedepends oninternal_metrics,asap-executor(itsDataStoretrait, IR and kernels),asap_sketchlib(sketch encodings), andserde,serde_json,serde_bytes,rmp-serde,zstd,ahash,libc,futures,tracingandclap.internal_metricsdepends onlibconly.libcis only a dev-dependency ofdata_plane(the benchmarks'posix_fadvise), now that the/procresident-memory reader is ininternal_metrics.data_planedropsserde_bytes,zstdandrmp-serde.asap_sketchlibmoves to its dev-dependencies, because only theview_read_benchexample uses it now.Cargo.lockgains the two packages and these dependency edges, and no versions change.Visibility changes
All other items keep the visibility they had in
data_plane:storage::store::RawData::readpub(crate)pubdata_plane::pushreads the raw storestorage::store::PartitionReads(type only;newstayspub(crate))pub(crate)pubRawData::read's signaturestorage::store::millispub(crate)(iningestion)pubingestionandengineuse itstorage::memory_budget::serve_view_cacheengine)pubenginespawns theview-cachethreadstorage::memory_budget::monitored_targetpubserve_view_cache, now in the same module, calls itGauges,render(data_plane::metrics_endpoint)pubinpub mod metricspub(crate)in a private moduleenginecalls themPhaseStats::render,Latency::render,PushMetrics::render,PushMetrics::render_gaugespubmetrics_endpoint::rendercalls themdata_plane::{store,persist,segment,window_cache,memory_budget,series_ids,metrics}pub modstorage::…andinternal_metrics::…engine.rsserve_view_cache) tostorage::memory_budget, next to the cgroup reads andmonitored_targetit calls. Its body is unchanged.engine.rsstill spawns it as theview-cachethread, because spawning is part ofEngineHandle::spawn.persist-Nthreads (serve_persist,release_persist_queue,PersistJob,PersistBarrier,PersistPool).serve_persisttakes the engine'sShared(itsMetrics,persist_queueandpersist_backlog), andPersistJob::Barriercarriesadvance_watermark's reply channel (PersistBarrier). To move them, storage would need a new interface for the backlog accounting, so they stay until step 5 splitsprecompute.view_tier(&EngineOptions)also stays, because it readsEngineOptions.Behavior: before → after
No change.
/metricswrites the same lines in the same order. The view-tier block now reads the tier fromGaugesinstead ofMetrics. The thread names, CLI flags, defaults and file formats are the same.Interfaces
QueryTimeResultsloses its default type parameter becauseUnansweredis the query engine's error, whichstoragecannot name. Its users writeQueryTimeResults<Unanswered>:QueryEngine,EngineHandle::query_time_resultsandGauges.Algorithm changes
None.
Decisions and open questions
Needs reviewer decision: none.
Decided (judgment calls made in this PR):
Gaugesandrenderstay in data-plane.renderreadsIngestionStats(precompute),ResultCache(query), andQueryTimeResultsandViewTier(storage). If it moved tointernal_metrics, that crate would depend on all three, and the design wants it to be a leaf. It is also a cycle today:storeusesPhaseStatsandTimer. A snapshot struct of plain numbers would be a new interface. So the exporter stays where the design puts wiring, and the measurement types move.Metrics::view_tier→Gauges::view_tier. It was the only field ofMetricsthat named a store type, and onlyrenderread it. The engine now keeps the tier inSharedand passes it torender.series_ids.rsgoes tostorage, notprecompute. The design's table puts it inprecompute. Butstore,segmentandpersistuseSeriesand the interner, andstoragemust not depend onprecompute. By the design's helper rule ("a helper two crates use goes in the lower of the two"), it goes tostorage. Step 4 may move it tocommon.millisandwindow_endgo tostorage::store. By the same rule:storeandpersistuse them, and so does ingestion.window_endwas alreadypub. Step 4 may move them tocommonwith the other time helpers.storagedepends onclap.ViewReadderivesclap::ValueEnumfor--view-read. Removing that derive would need a mirror enum in the binary, so the dependency stays.PhaseStats. That assertion now lives ininternal_metrics. The render assertions stay withrender, so no field becomespubfor a test.Verification
Both trees were built and tested on the same host, with one target directory each and
ulimit -nraised (see #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 --lockedThe four new suites are the unit tests and doc tests of
internal_metricsandstorage. The sorted lists of passing test names (test … ok) differ only by the planned test split:Every other test keeps its name, because the moved modules keep their names (
store::tests::…,persist::tests::…). The two moved integration tests also keep their binary names (view_cache_charge,series_ids).An independent review then checked the diff for non-move changes, visibility that is wider than needed, dependency direction, duplicated code and dead code. It found nothing blocking. The fourth commit applies its fixes:
serve_view_cachemoves next to the cgroup code inmemory_budget, somonitored_targetis private.Gaugesandrenderarepub(crate).internal_metricscrate doc no longer claims the gauges.storage::storeimports inengine.rsare merged, and theasap_executorimports join the external group.view_tiering.rs's header is rewrapped.The format, build, clippy and test gate above ran on that final head.
Whole-stack review fixes (fifth commit)
cargo fmt --all -- --checkinstead of a hand-written-plist, so a new crate is checked too (the README and pre-commit already run it). Later PRs no longer edit the list.resident_bytesmoves tointernal_metrics;libcbecomes a dev-dependency ofdata_plane.pub(crate)forstorageitems used only inside it:segment::{FORMAT_VERSION, is_sealed, max_end_ms, forget_after},persist::ViewIndex(and theFORMAT_VERSIONre-export), the state and text-key codecs (CompactKind,encode_states,decode_states,encode_text_keys,decode_text_keys),series_ids::labels_of_identity,WindowCache::{get_or_load, evict_idle}. Types other crates reach through apubmethod (WindowLocation,WindowSlot,Written,CgroupMemory, …) staypub.crates/storage/andcrates/internal-metrics/rows to the layout table.Follow-ups
series_ids.rsinstorageand has thestorage → internal-metricsedge; step 4 keptseries_ids,millisandwindow_endinstorage; step 5 moved thepersist-Nthreads tostorage.