Skip to main content

Module parallel

Module parallel 

Source
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:

  1. Optimistic Execution: Execute all operations in parallel without locking. Each operation tracks its read and write sets.

  2. Validation: Check if any read was invalidated by a concurrent write from an earlier transaction in the batch.

  3. Re-execution: Re-execute invalidated transactions with knowledge of their dependencies.

  4. Commit: Apply all writes in transaction order for determinism.

§Performance

Conflict RateExpected 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§

BatchRequest
A batch of operations to execute in parallel.
BatchResult
Result of executing a batch of operations.
ExecutionResult
Result of executing a single operation in the batch.
ParallelExecutor
Block-STM inspired parallel transaction executor.

Enums§

ExecutionStatus
Status of an operation execution.