Skip to main content

FSM Benchmark Report

This report documents the benchmark scripts, how to run them, the outputs they generate, and what the latest results mean for the FSM/heap manager implementation.

Scope

The benchmark set measures four things:

  1. RookDB's own FSM-backed heap manager performance.
  2. A SQLite comparison workload.
  3. A MySQL comparison workload.
  4. PostgreSQL comparison workloads using pgbench and pg_freespacemap.

The benchmark outputs are stored in the repository-root benchmark_runs/ directory. Intermediate scratch files are not meant to be committed.

How To Run The Benchmarks

Full Suite

Run every benchmark and refresh the comparison CSV:

./benchmarks/generate_comparison_csv.sh

This will, by default, run the full suite first and then generate benchmark_runs/benchmark_comparison.csv.

Run Everything Without Rebuilding the CSV

./benchmarks/run_all_benchmarks.sh

Aggregate Existing Outputs Only

RUN_BENCHMARKS=0 ./benchmarks/generate_comparison_csv.sh

Individual Scripts

./benchmarks/run_sqlite_bench.sh
./benchmarks/run_mysql_bench.sh
./benchmarks/run_pgbench.sh
./benchmarks/run_postgres_fsm_compare.sh

RookDB Native Benchmark Only

cargo run --bin benchmark_fsm_heap

You can also direct the JSON output explicitly:

cargo run --bin benchmark_fsm_heap -- --output benchmark_runs/latest_fsm_heap_benchmark.json

Script Summary

ScriptPurposeMain Output
benchmarks/run_all_benchmarks.shRuns the full benchmark suiteMultiple files in benchmark_runs/
benchmarks/generate_comparison_csv.shAggregates all result files into one comparison tablebenchmark_runs/benchmark_comparison.csv
benchmarks/run_sqlite_bench.shCreates, updates, deletes, and reports SQLite metricsbenchmark_runs/sqlite_benchmark.txt
benchmarks/run_mysql_bench.shCreates, updates, deletes, and reports MySQL metricsbenchmark_runs/mysql_benchmark.txt
benchmarks/run_pgbench.shRuns pgbench against PostgreSQLbenchmark_runs/pgbench_results.txt
benchmarks/run_postgres_fsm_compare.shMeasures PostgreSQL free-space behaviorbenchmark_runs/postgres_fsm_metrics.csv, benchmark_runs/postgres_fsm_summary.txt
cargo run --bin benchmark_fsm_heapBenchmarks the RookDB FSM/heap stackbenchmark_runs/latest_fsm_heap_benchmark.json

Required Environment

Shared

  • Rust toolchain and Cargo
  • Repository root as the working directory when invoking the scripts
  • A writable benchmark_runs/ directory

SQLite

  • sqlite3 available on PATH

MySQL

  • mysql client available on PATH
  • A reachable MySQL server
  • Optional environment variables:
    • MYSQL_HOST
    • MYSQL_PORT
    • MYSQL_USER
    • MYSQL_PASSWORD
    • MYSQL_DATABASE

PostgreSQL / pgbench

  • psql and pgbench available on PATH
  • A reachable PostgreSQL server
  • Optional environment variables:
    • PGHOST
    • PGPORT
    • PGUSER
    • PGPASSWORD
    • PGDATABASE
    • PGBENCH_SCALE
    • PGBENCH_CLIENTS
    • PGBENCH_JOBS
    • PGBENCH_TIME

Output Files

The canonical benchmark output set is:

  • benchmark_runs/latest_fsm_heap_benchmark.json
  • benchmark_runs/benchmark_history.csv
  • benchmark_runs/benchmark_history.jsonl
  • benchmark_runs/benchmark_comparison.csv
  • benchmark_runs/sqlite_benchmark.txt
  • benchmark_runs/mysql_benchmark.txt
  • benchmark_runs/pgbench_results.txt
  • benchmark_runs/postgres_fsm_metrics.csv
  • benchmark_runs/postgres_fsm_summary.txt
  • benchmark_runs/initial_phase_results.json

Temporary SQLite files such as sqlite_bench.db, sqlite_bench.db-wal, and sqlite_bench.db-shm are intermediate artifacts and are intentionally not part of the final benchmark deliverables.

Latest RookDB Benchmark Results

Source: benchmark_runs/latest_fsm_heap_benchmark.json

MetricValue
Run ID1776859982
Small inserts20000
Large inserts1000
Lookup samples1000
Inserted total21000
Scanned total21000
Small insert TPS21291.0861
Large insert TPS16930.2971
Point lookup OPS515331.1002
Sequential scan TPS2167611.4872
FSM rebuild seconds0.005375
Heap pages269
FSM pages3
Pages used with tuples268
Avg tuples per used page78.36
Avg free bytes on used pages94.45
Oversized tuple rejectedtrue
FSM rebuild search found pagetrue

Cross-Database Comparison

Source: benchmark_runs/benchmark_comparison.csv

EngineRows ConfiguredInsert secUpdate secDelete secRows After DeleteAvg Payload LenSmall TPSLarge TPSLookup OPSScan TPSFSM Rebuild secAvg FSM Free Bytespgbench TPSpgbench Latency ms
rookdb_fsm_heap21000NANANANANA21291.0916930.30515331.102167611.490.005375NANANA
sqlite1000000109000055.56NANANANANANANANA
mysql1000001009000055.56NANANANANANANANA
postgres_fsm100000090055.56NANANANANA2269.71NANA
pgbenchNANANANANANANANANANANANA3867.8909252.068

Analysis

Storage Utilization

The latest RookDB run reports 269 heap pages and only 3 FSM pages. Of those heap pages, 268 hold tuples. The average free space on used pages is 94.45 bytes, which means the heap is packed extremely tightly. On an 8192-byte page, that leaves roughly 1.15% free space and implies about 98.85% average utilization on active pages.

This is the expected effect of page-level free-space selection: the FSM keeps inserts routed to pages that still have room, and the heap manager reuses available slot space before extending the table.

Insert Performance

The latest RookDB run shows:

  • Small insert throughput: 21291.09 TPS
  • Large insert throughput: 16930.30 TPS

Compared with the earlier history point at run 1776596962, small inserts improved from 18852.96 TPS to 21291.09 TPS, and large inserts improved from 13036.05 TPS to 16930.30 TPS. That is a meaningful gain for both tuple sizes, especially for larger payloads.

Interpretation:

  • The FSM search path is finding viable pages efficiently.
  • Slot reuse and header/page update logic are not introducing a visible bottleneck.
  • Large tuple handling is scaling better than earlier runs, which suggests the current page reuse and allocation path is stable.

Read Performance

The latest run reports:

  • Point lookup throughput: 515331.10 OPS
  • Sequential scan throughput: 2167611.49 TPS

These are very strong numbers, but they should be read carefully. This benchmark is single-process and can be sensitive to page cache warmth, so lookup and scan values should be treated as best-case operational performance unless you run repeated cold/warm trials.

Still, the trend is positive: point lookups and scans remain correct and fast while the storage layer is under sustained insert pressure.

Recovery and Robustness

The FSM rebuild time in the latest run is 0.005375 seconds. That is fast enough to support rebuild-on-open behavior without turning recovery into a user-visible penalty.

The benchmark also confirms that:

  • oversized tuples are rejected correctly
  • scanned_total == inserted_total
  • rebuilding the FSM still finds a valid page

This means the storage layer remains correct while the benchmarked performance improves.

Cross-Engine Context

The comparison CSV is useful as an engineering snapshot, not a perfectly identical workload comparison.

  • RookDB reports storage-engine metrics like TPS, OPS, and FSM rebuild time.
  • SQLite and MySQL report operation durations and post-delete state.
  • PostgreSQL FSM metrics report average free bytes.
  • pgbench reports throughput and latency for a synthetic transactional workload.

Because the workloads are not identical, the table should be read as a qualitative comparison set rather than a strict apples-to-apples TPC-style benchmark.

Trend Analysis

Recent RookDB runs in benchmark_history.csv show a clear progression:

Run IDSmall TPSLarge TPSLookup OPSScan TPSRebuild sec
177659696218852.957813036.053443332.407847035.36730.009143
177662014021265.655616456.153577746.64112166632.84310.006503
177685998221291.086116930.2971515331.10022167611.48720.005375

Read this as:

  • insert throughput improved and then stabilized at a stronger level
  • rebuild time kept decreasing
  • read metrics remained correct and became much faster in the latest runs

Benchmark Method Notes

  • The benchmark suite is single-process for the RookDB path.
  • Results can vary with OS cache state and background system load.
  • External engine scripts are shell-based and use elapsed second timing.
  • For submission-quality reporting, repeated runs and median values are preferable.

Script Inputs And Outputs

RookDB Native Benchmark

Command:

cargo run --bin benchmark_fsm_heap

Main outputs:

  • benchmark_runs/latest_fsm_heap_benchmark.json
  • benchmark_runs/benchmark_history.csv
  • benchmark_runs/benchmark_history.jsonl

Comparison Aggregation

Command:

./benchmarks/generate_comparison_csv.sh

Main output:

  • benchmark_runs/benchmark_comparison.csv

SQLite, MySQL, pgbench, PostgreSQL FSM

Commands:

./benchmarks/run_sqlite_bench.sh
./benchmarks/run_mysql_bench.sh
./benchmarks/run_pgbench.sh
./benchmarks/run_postgres_fsm_compare.sh

Main outputs:

  • benchmark_runs/sqlite_benchmark.txt
  • benchmark_runs/mysql_benchmark.txt
  • benchmark_runs/pgbench_results.txt
  • benchmark_runs/postgres_fsm_metrics.csv
  • benchmark_runs/postgres_fsm_summary.txt

Cleanup Policy

Intermediate files are removed after the benchmark summary is produced. Examples include:

  • transient SQLite database files and WAL/SHM sidecars
  • temporary fsm_heap_bench_*.dat.fsm files used during benchmark runs

Final result files remain in benchmark_runs/ so the documentation and comparison CSV can refer to them directly.

Conclusion

The benchmark set shows that RookDB's FSM-backed heap manager is behaving as intended:

  • heap pages are densely utilized
  • insert throughput is strong for both small and large tuples
  • point lookups and scans are fast
  • FSM rebuild is cheap enough to support recovery
  • correctness checks stay green throughout the run

This makes the current documentation package complete for the benchmark portion of the submission requirements.