Skip to content
This repository was archived by the owner on Aug 7, 2026. It is now read-only.

feat(smt): Fjall storage backend for large_forest::PersistentBackend - #1104

Open
battlmonstr wants to merge 68 commits into
0xMiden:nextfrom
battlmonstr:smt-forest-fjall
Open

feat(smt): Fjall storage backend for large_forest::PersistentBackend#1104
battlmonstr wants to merge 68 commits into
0xMiden:nextfrom
battlmonstr:smt-forest-fjall

Conversation

@battlmonstr

@battlmonstr battlmonstr commented Jul 29, 2026

Copy link
Copy Markdown

Overview

This is a follow-up to PR #1101 and depends on it.
#1101 started supporting alternative storage backends for large SMT, and covered smt::large::storage module.
This PR covers smt::large_forest::backend::persistent module.

PersistentBackend (in mod.rs) used to have business logic to store a large forest SMT. That business logic was wired to RocksDB but in theory could be applied to any key-value storage mechanism.

The PersistentBackend is refactored to work on top of abstract KVDB traits introduced in PR #1101.
A Fjall database backend is added.

Contents

The PR commits are organized in this sequence:

  1. Preparational commits and refactorings.
  2. PersistentBackend refactoring onto KVDB traits. It is ported method by method, and finalized with a code cleanup.
  3. Generalizing PersistentBackend to KVDBPersistentBackend and introducing a persistent-forest-rocks feature flag to prepare for alternative backends.
  4. Fjall backend with persistent-forest-fjall feature flag.

Each intermediate commit produces a valid state in which tests and benchmarks pass.
It is recommended to do code review sequentially commit by commit.

Tests

make test-large-smt-forest
make test-large-smt-forest-fjall

Benchmarks

macOS 26, Mac Mini M4 Pro 10+4 cores

test RocksDB Fjall
test-large-smt-forest 1.5 sec 2.4 sec
bench-large-smt-forest-rocksdb - -48%..+35%

to support RustRover IDE
Without --reset it is not possible to run the command twice in a row.
It fails with an error when running on an existing db.
The existing target runs both smt::large and smt::large_forest unit tests.
Running only smt::large is useful until the large_forest module is refactored.
The Makefile declares bench-large-smt-* targets to run benchmarks in the miden-crypto binary (main.rs).

There are 2 more related benchmarks:
* "criterion" - miden-crypto/benches/large_smt.rs
* "codspeed" - benches/smt-codspeed/benches/smt_codspeed.rs

It is useful to be able to run them in isolation for alternative backends comparison.
This is needed to make RocksDbConfig backend-agnostic.
write_buffer_manager creation relies on rocksdb library.
for reuse across alternative backends
The constants are shared among alternative backends.
Defines traits to be implemented by alternative backends.
Adds a RocksKVDB implementation to migrate RocksDB-specific code from RocksDbStorage.
Replaces the hand-rolled RocksDbSubtreeIterator with a chain of six
KVDBReader::iter calls (one per subtree depth CF), each mapped to
Subtree deserialization.
@github-actions

Copy link
Copy Markdown

Automated check (CONTRIBUTING.md)

Findings:

Recommendations:

  • Consider adding a Test plan or clear review steps.

Next steps:

@battlmonstr

Copy link
Copy Markdown
Author

/quality-review

@battlmonstr
battlmonstr force-pushed the smt-forest-fjall branch 2 times, most recently from 247f78e to 49be44b Compare July 30, 2026 16:06
KVDB traits implementation using Fjall database.
This backend can be selected by smt-kvdb-fjall feature flag.
Similar to "bench-large-smt-criterion-rocksdb".
Useful for performance comparison of alternative backends.
This is a preparation to schema setup refactoring.
Move merge_batches from smt::large_forest to smt::large to implement KVDBBatch.append().
The KVDB implementations must not depend on any particular schema.
The schema configuration is separated to KVDBSchemaFactory implementations.
Move related code there: new, configure_smt_cf_options, configure_block_table_options.
The constants are shared among alternative schema factories.
Adds a RocksKVDB implementation to migrate RocksDB-specific code from PersistentBackend.
Previously persistent-forest controlled both PersistentBackend and rocksdb.
Now it is repurposed to only control a generic KVDBPersistentBackend,
and a new flag controls binding it to RocksDB.

persistent-forest-default flag is needed for --all-features builds.
In such build it gets enabled, and effectively disables non-default backends.
Fjall database binding of PersistentBackend.
This backend can be selected by persistent-forest-fjall feature flag.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant