Skip to content

chonpsk/Toy-evm

Repository files navigation

EVM Parallel Scheduler

Usage

CLI supports generation, serial/parallel execution, and preset scenarios.

Generate Block

# Custom
cargo run generate -n 100 -k 1000 --conflict_ratio 0.2 --cold_ratio 0.1 -s 42 -o block.json

# Preset (small: 10tx, medium:100tx, large:1000tx)
cargo run preset --small -s 42 -o block.json
  • -n: Number of transactions; -k: Key space; -s: Seed; -o: Output file.

Execution

# Serial baseline
cargo run serial -i block.json

# Parallel (outputs metrics JSON)
cargo run parallel -i block.json
  • Example metrics:
    {
      "waves": 5,
      "avg_wave_size": 20.0,
      "speedup_vs_serial": 3.2,
      "conflict_rate": 0.2,
      "preexec_precision": 0.85,
      "preexec_recall": 0.95,
      "p50_tx_latency_us": 1500.0,
      "approx_iops": 50000.0
    }

Architecture

see architecture.png

  • Executor: Constructed by Scheduler and KV

Testing

cargo test 

Benchmark

small

{
  "approx_iops": 145.63324900032072,
  "avg_wave_size": 3.3333333333333335,
  "conflict_rate": 0.2,
  "gas_parallel": 26420,
  "gas_serial": 26420,
  "p50_tx_latency_us": 2.0,
  "p95_tx_latency_us": 172.0,
  "p99_tx_latency_us": 0.0,
  "preexec_precision": 0.0225,
  "preexec_recall": 1.0,
  "speedup_vs_serial": 1.097472023697938,
  "waves": 3
}

medium

{
  "approx_iops": 213.91552310462728,
  "avg_wave_size": 33.333333333333336,
  "conflict_rate": 0.2,
  "gas_parallel": 462183,
  "gas_serial": 462183,
  "p50_tx_latency_us": 3.0,
  "p95_tx_latency_us": 213.0,
  "p99_tx_latency_us": 279.0,
  "preexec_precision": 0.03367853350418217,
  "preexec_recall": 1.0,
  "speedup_vs_serial": 0.8006634140047395,
  "waves": 3
}

large

{
  "approx_iops": 166.5213768494842,
  "avg_wave_size": 250.0,
  "conflict_rate": 0.2,
  "gas_parallel": 3654330,
  "gas_serial": 3654330,
  "p50_tx_latency_us": 3.0,
  "p95_tx_latency_us": 199.0,
  "p99_tx_latency_us": 385.0,
  "preexec_precision": 0.030603736185503008,
  "preexec_recall": 1.0,
  "speedup_vs_serial": 0.6983103463846523,
  "waves": 4
}

The key space is small so that it is hard to parallel execute.

All operations being executed deterministically is the most critical factor for correctness. Operations like keccak, which must be performed online, can trigger latent conflicts. Therefore, when a conflict occurs, all transactions in the same wave with an ID greater than that of the affected transaction must be redone.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages