store: remove sqlite table size analysis#2028
Open
bigeez wants to merge 7 commits into0xMiden:nextfrom
Open
Conversation
The periodic `analyze_table_sizes` task ran every 5 minutes and issued two queries against the `dbstat` virtual table, which performs a full page-by-page scan of the database. Under write contention this scan could block concurrent writers for 30s+, far outweighing any telemetry benefit. Remove the spawned interval task from `server/mod.rs`, and delete `analyze_table_sizes` from `Db` and `State`. Disk usage can be inspected on demand by querying SQLite snapshots or monitoring the data-directory at the filesystem level. Closes 0xMiden#1964
Replace the removed dbstat-based analysis with a 5-minute interval task that reads on-disk byte sizes using std::fs::metadata and std::fs::read_dir. No SQLite connections are opened, so there is zero read-lock contention with concurrent writers. Tracked paths: - miden-store.sqlite3 (main database) - miden-store.sqlite3-wal and -shm (SQLite WAL sidecars) - blocks/ (block store, recursive) - accounttree/ and nullifiertree/ (RocksDB trees, rocksdb feature only)
Comment on lines
+346
to
+349
| #[cfg(feature = "rocksdb")] | ||
| account_tree: dir_size_bytes(&data_dir.join("accounttree")), | ||
| #[cfg(feature = "rocksdb")] | ||
| nullifier_tree: dir_size_bytes(&data_dir.join("nullifiertree")), |
Collaborator
There was a problem hiding this comment.
@kkovaacs do we need to explore the directory for rocksdb, or can we be more specific like with sqlite?
- Use `Duration::from_mins(5)` (stabilised in Rust 1.91) - Replace `info!`/`warn!` events with `info_span!` and OTel span attributes - Use `db.*` attribute naming to align with OTel conventions - Drop `append_path_str` helper in favour of direct `data_dir.join(...)` calls - Add `ToValue for u64` to support disk-size span attributes
- Replace recursive walk with iterative loop to avoid stack overflow on deeply nested directories - Use match-with-guards in loop body instead of nested if-let
Maintainer prefers the original if-let style over match-with-guards in the context of the iterative walk.
Mirko-von-Leipzig
approved these changes
May 2, 2026
Collaborator
Mirko-von-Leipzig
left a comment
There was a problem hiding this comment.
Thank you! Lets wait for @kkovaacs to also TAL.
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.
Closes #1964
Summary
Removes the
analyze_table_sizesperiodic background task and its supporting methods.The task ran on a 5-minute
tokio::time::intervalinspawn_grpc_serversand issued two queries against SQLite'sdbstatvirtual table (a per-page scan) plus apragma_page_count()/pragma_page_size()query. Under write contention the scan held a read lock long enough to block concurrent writers for 30s+, making it a net negative for the performance it was meant to observe.Changes
server/mod.rs— removed the spawned interval task; cleaned up now-unusedDurationimport and updated stale doc commentsdb/mod.rs— removedanalyze_table_sizesmethod; cleaned up now-unusedQueryableByNameimportstate/mod.rs— removedanalyze_table_sizeswrapperDisk usage can be inspected on demand via SQLite snapshots or by monitoring the data-directory at the filesystem level (
miden-store.sqlite3,blocks/, proof files).Test plan
cargo check -p miden-node-storepassesanalyze_table_sizes,dbstat, orpragma_pagein the store crate