feat: add the tsdb benchmark subject #7

Merged
aleksei merged 2 commits from feat/tsdb-benchmarks into main 2026-10-21 10:59:54 +00:00
Owner

Add a criterion subject tsdb that compares the time-series store across the two deployment profiles: NATS + ClickHouse and in-process fjall + Parquet.

What it measures

Direct port comparison (no broker):

  • tsdb insert — 1 and 1,000 rows, ClickHouse vs Parquet; the table is cleared outside the timer.
  • tsdb query — 10,000 seeded rows, value=gt=5000, sort +date, limit 100; the seed is outside the timer.
  • tsdb purge — 1,000 seeded rows, id=lt="00000500"; the seed is outside the timer and the remaining 500 rows are asserted.

Full persistent projection:

  • tsdb persistent projection — persistent CREATE messages are published to EntityProjectTsdbUnit over NATS + ClickHouse and over inproc + Parquet; 1 and 100 messages per iteration. The timer covers publish + projection + TsdbUnit::insert; it ends when the expected row count is visible, so the polling latency of the asynchronous projection is included (the port has no completion event).

Skip rules

  • The ClickHouse direct half requires CLICKHOUSE_URL.
  • The NATS + ClickHouse stack requires both NATS_URL and CLICKHOUSE_URL.
  • The Parquet direct half and the inproc + Parquet stack always run against a TempDir.

Local quick results (no services, cargo bench -p eve_e2e -- tsdb --quick)

tsdb insert/parquet/1                 ~0.22 ms
tsdb insert/parquet/1000              ~0.51 ms
tsdb query/parquet                    ~8.4 ms
tsdb purge/parquet                    ~1.4 ms
tsdb persistent projection/parquet/1  ~3.35 ms
tsdb persistent projection/parquet/100 ~7.86 ms

The network half was not run here because NATS/ClickHouse are not up. With the backends:

docker compose up -d nats clickhouse
NATS_URL=nats://127.0.0.1:4222 \
CLICKHOUSE_URL=http://root:root1234@127.0.0.1:8123 \
  cargo bench -p eve_e2e -- tsdb

Docs

  • eve_e2e/benches/bench.rs: registers the ninth subject.
  • adr/bench.md: describes the direct and full-stack comparisons, the skip rules and the polling caveat.
  • README.md: subject list, example command and backend variables.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo bench -p eve_e2e -- tsdb --quick (local halves; network halves skip cleanly)
  • cargo test -p eve_e2e --test broker --test db --test tsdb --test storage --test app — all pass.
Add a criterion subject `tsdb` that compares the time-series store across the two deployment profiles: NATS + ClickHouse and in-process fjall + Parquet. ## What it measures **Direct port comparison** (no broker): - `tsdb insert` — 1 and 1,000 rows, ClickHouse vs Parquet; the table is cleared outside the timer. - `tsdb query` — 10,000 seeded rows, `value=gt=5000`, sort `+date`, limit 100; the seed is outside the timer. - `tsdb purge` — 1,000 seeded rows, `id=lt="00000500"`; the seed is outside the timer and the remaining 500 rows are asserted. **Full persistent projection**: - `tsdb persistent projection` — persistent `CREATE` messages are published to `EntityProjectTsdbUnit` over NATS + ClickHouse and over inproc + Parquet; 1 and 100 messages per iteration. The timer covers publish + projection + `TsdbUnit::insert`; it ends when the expected row count is visible, so the polling latency of the asynchronous projection is included (the port has no completion event). ## Skip rules - The ClickHouse direct half requires `CLICKHOUSE_URL`. - The NATS + ClickHouse stack requires both `NATS_URL` and `CLICKHOUSE_URL`. - The Parquet direct half and the inproc + Parquet stack always run against a `TempDir`. ## Local quick results (no services, `cargo bench -p eve_e2e -- tsdb --quick`) ``` tsdb insert/parquet/1 ~0.22 ms tsdb insert/parquet/1000 ~0.51 ms tsdb query/parquet ~8.4 ms tsdb purge/parquet ~1.4 ms tsdb persistent projection/parquet/1 ~3.35 ms tsdb persistent projection/parquet/100 ~7.86 ms ``` The network half was not run here because NATS/ClickHouse are not up. With the backends: ```sh docker compose up -d nats clickhouse NATS_URL=nats://127.0.0.1:4222 \ CLICKHOUSE_URL=http://root:root1234@127.0.0.1:8123 \ cargo bench -p eve_e2e -- tsdb ``` ## Docs - `eve_e2e/benches/bench.rs`: registers the ninth subject. - `adr/bench.md`: describes the direct and full-stack comparisons, the skip rules and the polling caveat. - `README.md`: subject list, example command and backend variables. ## Verification - `cargo fmt --all -- --check` - `cargo clippy --workspace --all-targets -- -D warnings` - `cargo bench -p eve_e2e -- tsdb --quick` (local halves; network halves skip cleanly) - `cargo test -p eve_e2e --test broker --test db --test tsdb --test storage --test app` — all pass.
Author
Owner

Network half is up (existing eve-nats and eve-clickhouse containers: NATS 2.10, ClickHouse 25.2.2) and both halves now run. This also caught a real benchmark bug: the schema had no required fields, so ClickHouse 25 rejected the nullable sorting key; fixed by adding "required": ["id", "date", "value"] (commit 51b1137).

Command:

NATS_URL=nats://127.0.0.1:4222 \
CLICKHOUSE_URL=http://root:root1234@127.0.0.1:8123 \
  cargo bench -p eve_e2e -- tsdb

Results (median)

Benchmark ClickHouse Parquet Ratio
tsdb insert/1 57.98 ms 0.254 ms Parquet ~228x faster
tsdb insert/1000 58.39 ms 0.907 ms Parquet ~64x faster
tsdb insert/1000 throughput 17.1k rows/s 1.10M rows/s Parquet ~64x
tsdb query (10k seeded, filter+sort+limit) 5.92 ms 8.45 ms ClickHouse ~1.43x faster
tsdb purge (1k seeded, 500 removed) 17.74 ms 2.18 ms Parquet ~8.1x faster
tsdb persistent projection/1 62.69 ms 3.52 ms Parquet ~17.8x faster
tsdb persistent projection/100 123.99 ms 11.30 ms Parquet ~11.0x faster
tsdb persistent projection/100 throughput 806 rows/s 8.85k rows/s Parquet ~11.0x faster

Interpretation

  • ClickHouse insert latency is dominated by the adapter's async_insert=1 path: the one-row and 1,000-row batches both take ~58 ms, which matches ClickHouse's adaptive async-insert flush timeout (async_insert_busy_timeout_ms=200, min 50 ms). So the 1-row comparison is a fixed flush-wait comparison, not a storage comparison; the 1,000-row throughput is the useful storage number.
  • Once that fixed cost is paid, ClickHouse inserts 1,000 rows in the same ~58 ms (~17k rows/s), while Parquet writes one part in ~0.9 ms (~1.1M rows/s).
  • Reads are the opposite: ClickHouse answers the filtered/sorted page in ~5.9 ms, Parquet scans its parts in-process in ~8.5 ms.
  • Purge is much cheaper in Parquet for this 1k-row table (rewrite) than the ClickHouse ALTER DELETE + OPTIMIZE mutation.
  • The full persistent-projection stack is ~18x faster at one message and ~11x faster at 100 messages on inproc+Parquet, mostly because each ClickHouse insert batch pays the async flush wait and NATS adds a network round trip.
  • The full-stack timer includes polling until the expected row count is visible; the TsdbUnit port has no completion event. Both halves pay the same polling latency.

These are single-run numbers on a shared host; use --save-baseline / --baseline for regression comparisons. The benchmark wipes NATS streams and ClickHouse tables on start, like the e2e suite.

Network half is up (existing `eve-nats` and `eve-clickhouse` containers: NATS 2.10, ClickHouse 25.2.2) and both halves now run. This also caught a real benchmark bug: the schema had no `required` fields, so ClickHouse 25 rejected the nullable sorting key; fixed by adding `"required": ["id", "date", "value"]` (commit `51b1137`). Command: ```sh NATS_URL=nats://127.0.0.1:4222 \ CLICKHOUSE_URL=http://root:root1234@127.0.0.1:8123 \ cargo bench -p eve_e2e -- tsdb ``` ## Results (median) | Benchmark | ClickHouse | Parquet | Ratio | |---|---:|---:|---:| | `tsdb insert/1` | 57.98 ms | 0.254 ms | Parquet ~228x faster | | `tsdb insert/1000` | 58.39 ms | 0.907 ms | Parquet ~64x faster | | `tsdb insert/1000` throughput | 17.1k rows/s | 1.10M rows/s | Parquet ~64x | | `tsdb query` (10k seeded, filter+sort+limit) | 5.92 ms | 8.45 ms | ClickHouse ~1.43x faster | | `tsdb purge` (1k seeded, 500 removed) | 17.74 ms | 2.18 ms | Parquet ~8.1x faster | | `tsdb persistent projection/1` | 62.69 ms | 3.52 ms | Parquet ~17.8x faster | | `tsdb persistent projection/100` | 123.99 ms | 11.30 ms | Parquet ~11.0x faster | | `tsdb persistent projection/100` throughput | 806 rows/s | 8.85k rows/s | Parquet ~11.0x faster | ## Interpretation - ClickHouse `insert` latency is dominated by the adapter's `async_insert=1` path: the one-row and 1,000-row batches both take ~58 ms, which matches ClickHouse's adaptive async-insert flush timeout (`async_insert_busy_timeout_ms=200`, min 50 ms). So the 1-row comparison is a fixed flush-wait comparison, not a storage comparison; the 1,000-row throughput is the useful storage number. - Once that fixed cost is paid, ClickHouse inserts 1,000 rows in the same ~58 ms (~17k rows/s), while Parquet writes one part in ~0.9 ms (~1.1M rows/s). - Reads are the opposite: ClickHouse answers the filtered/sorted page in ~5.9 ms, Parquet scans its parts in-process in ~8.5 ms. - Purge is much cheaper in Parquet for this 1k-row table (rewrite) than the ClickHouse `ALTER DELETE` + `OPTIMIZE` mutation. - The full persistent-projection stack is ~18x faster at one message and ~11x faster at 100 messages on inproc+Parquet, mostly because each ClickHouse insert batch pays the async flush wait and NATS adds a network round trip. - The full-stack timer includes polling until the expected row count is visible; the `TsdbUnit` port has no completion event. Both halves pay the same polling latency. These are single-run numbers on a shared host; use `--save-baseline` / `--baseline` for regression comparisons. The benchmark wipes NATS streams and ClickHouse tables on start, like the e2e suite.
aleksei deleted branch feat/tsdb-benchmarks 2026-10-21 10:59:54 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
zoo/eve!7
No description provided.