Skip to main content

Crate calimero_store_rocksdb

Crate calimero_store_rocksdb 

Source
Expand description

§RocksDB Storage Backend

This module provides a RocksDB-based implementation of the Database trait.

§Why No Connection Pool?

RocksDB already manages resources internally and does not require an external connection pool. Here’s why:

  1. Thread Safety: The DB object is thread-safe and designed to be shared across multiple threads. A single DB instance can handle concurrent read/write operations safely.

  2. Internal File Handle Management: RocksDB uses an LRU cache to manage open file handles internally. The max_open_files option controls how many SST files RocksDB keeps open simultaneously. When this limit is reached, RocksDB automatically closes least-recently-used file handles.

  3. Block Cache: RocksDB maintains its own block cache for frequently accessed data, reducing disk I/O without external caching.

  4. File Locking: RocksDB uses file locking to prevent multiple processes from opening the same database. Only one DB instance can exist per path per process.

  5. The Store Wrapper: The higher-level Store type already wraps the database in an Arc, allowing it to be cloned and shared efficiently across the application.

// Open the database once
let store = Store::open::<RocksDB>(&config)?;

// Clone and share the store (cheap Arc clone)
let store_clone = store.clone();

// Both handles share the same underlying RocksDB instance

§Configuration

Resource limits are configured through RocksDB’s native options in the open method:

  • max_open_files: Controls file descriptor usage (default: 256)
  • Block cache: 128MB LRU cache for frequently accessed blocks

If you need to adjust these settings, modify the Options in RocksDB::open().

Structs§

RocksDB
RocksDB database wrapper implementing the Database trait.