Expand description
Block-STM inspired parallel transaction execution.
Executes a batch of operations in parallel optimistically, validates for conflicts, and re-executes conflicting transactions. This is inspired by Aptos Block-STM and provides significant speedup for batch-heavy workloads like ETL imports.
§Algorithm
The execution follows four phases:
-
Optimistic Execution: Execute all operations in parallel without locking. Each operation tracks its read and write sets.
-
Validation: Check if any read was invalidated by a concurrent write from an earlier transaction in the batch.
-
Re-execution: Re-execute invalidated transactions with knowledge of their dependencies.
-
Commit: Apply all writes in transaction order for determinism.
§Performance
| Conflict Rate | Expected Speedup |
|---|---|
| 0% | 3-4x on 4 cores |
| <10% | 2-3x |
| >30% | Falls back to sequential |
§Example
use grafeo_engine::transaction::parallel::{ParallelExecutor, BatchRequest};
let executor = ParallelExecutor::new(4); // 4 workers
let batch = BatchRequest::new(vec![
"CREATE (n:Person {id: 1})",
"CREATE (n:Person {id: 2})",
"CREATE (n:Person {id: 3})",
]);
let result = executor.execute_batch(batch, |_idx, _op, _result| {
// execute each operation against the store
});
assert!(result.all_succeeded());Structs§
- Batch
Request - A batch of operations to execute in parallel.
- Batch
Result - Result of executing a batch of operations.
- Execution
Result - Result of executing a single operation in the batch.
- Parallel
Executor - Block-STM inspired parallel transaction executor.
Enums§
- Execution
Status - Status of an operation execution.