You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: use spawn_blocking instead of runtime tasks for compaction (#527)
<!-- greptile_comment -->
## Greptile Summary
Updated On: 2025-09-04 05:20:29 UTC
This PR refactors RocksDB compaction operations in the ledger truncation
process to use `tokio::task::spawn_blocking` instead of async tasks. The
changes address a critical performance issue where CPU-intensive RocksDB
compaction operations were blocking the Tokio async runtime threads.
**Key Changes:**
1. **In `ledger_truncator.rs`**: Replaces the coordinated async approach
using `JoinSet` with three separate `spawn_blocking` calls. Previously,
the code used `JoinSet` to run concurrent async tasks for compaction and
awaited their completion. Now it spawns blocking tasks that run
independently in dedicated thread pools.
2. **In `store/api.rs`**: Adds performance measurement instrumentation
to the `compact_slot_range_cf` method, wrapping compaction operations
with timing measurements and logging duration for operational
visibility.
The changes integrate with the existing RocksDB column family system
defined in the ledger's database layer. The compaction operations target
specific column families like `Blocktime`, `TransactionStatus`,
`Transaction`, `TransactionMemos`, and `AddressSignatures`, which are
part of the structured database schema for managing Solana transaction
data.
This refactoring follows a common async Rust pattern of moving blocking
operations to dedicated thread pools to keep the main async runtime
responsive for I/O-bound operations.
## Confidence score: 2/5
- This PR introduces a significant behavioral change that could cause
race conditions or incomplete operations
- Score reflects the removal of synchronization without adding proper
coordination mechanisms
- Pay close attention to `ledger_truncator.rs` as it removes critical
awaiting of compaction completion
<!-- /greptile_comment -->
---------
Co-authored-by: Gabriele Picco <piccogabriele@gmail.com>
0 commit comments