Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mz-benchmark

БесплатноБез исполняемых скриптовНе проверен

Add/modify/debug Materialize perf benchmark scenarios. Three frameworks: Feature Benchmark (single-op micro), Scalability Test (SQL throughput under…

MaterializeIncот MaterializeInc★ 6 417 звёзд на GitHub

Об этом скилле

Benchmark Frameworks

Materialize has some benchmark frameworks targetting local Docker, each suited to different performance concerns. Choose the right one based on what you're measuring.

Decision Guide

Concern Framework Best For
Single-operation latency Feature Benchmark "How fast is this SELECT / INSERT / CREATE INDEX?"
SQL throughput under concurrency Scalability Test "How many QPS can we sustain at 1/4/16/64/256 concurrent clients?"
Sustained performance over time Parallel Benchmark "Does latency degrade over a 2-minute mixed workload?"

A Rust cargo bench target must reference the production allocator with a mz-alloc-default dev-dependency and use mz_alloc_default as _; (see src/repr/benches/row.rs). Without it the bench runs on the system allocator, not jemalloc.

Scalability Test and Parallel Benchmark connect with psycopg 3 and leave prepare_threshold at its default of 5, so a query switches to a prepared statement on its sixth execution per connection. Set it explicitly and warm connections up when per-query latency matters.


1. Feature Benchmark (Micro-benchmarks)

Measures wall-clock time of individual SQL operations without concurrency. Uses testdrive fragments. Great for regression-testing specific code paths.

How to Add a Scenario

  1. Add a class in one of the scenarios/*.py files. Extend Scenario (default, runs in CI), ScenarioBig (longer, opt-in), or ScenarioDisabled.
  2. Implement benchmark() returning a Td(...) with timing markers (/* A */ and /* B */).
  3. Optionally implement shared(), init(), before() if setup is required.

Scenario Template

from materialize.feature_benchmark.action import TdAction
from materialize.feature_benchmark.measurement_source import MeasurementSource, Td
from materialize.feature_benchmark.scenario import Scenario

class MyCategory(Scenario):
    """Group parent - won't run (not a leaf)."""
    pass

class MySpecificBenchmark(MyCategory):
    """Leaf class - this runs."""

    def init(self) -> list[TdAction]:
        return [
            self.table_ten(),  # Creates table 'ten' with values 0-9
            TdAction("""
                > CREATE TABLE t1 (f1 INTEGER);
                > INSERT INTO t1 SELECT {unique_values} FROM {join};
                > SELECT COUNT(*) FROM t1;
                {n}
            """.format(
                unique_values=self.unique_values(),
                join=self.join(),
                n=self.n(),
            )),
        ]

    def benchmark(self) -> MeasurementSource:
        return Td("""
> SELECT 1;
  /* A */
1

> SELECT COUNT(*) FROM t1 WHERE f1 % 2 = 0;
  /* B */
{half_n}
""".format(half_n=self.n() // 2))

Timing Markers

  • /* A */ - Start marker. Measurement begins AFTER this completes.
  • /* B */ - End marker. Measurement ends when this completes.
  • Measures: time from end of A to end of B.
  • For a single query, use SELECT 1; /* A */ as a dummy start to not measure the overhead of Testdrive starting up.

Scenario Phases (execution order)

  1. shared() - Runs once for BOTH instances (e.g., create Kafka topics)
  2. init() - Runs once per instance (create tables, populate data)
  3. before() - Runs before EACH iteration (restart, cleanup)
  4. benchmark() - Runs repeatedly, measured

The result is the minimum (MinAggregation) after discarding the first 3 measurements. ProbForMin(threshold=0.90) in test/feature-benchmark/mzcompose.py can end a scenario after 6 measurements, so the verdict can rest on 3 values and one outlier can flip it. Read the raw per-iteration values before trusting a regression or improvement.

The measured cluster cluster_default is an unmanaged replica on the clusterd container, configured by the Clusterd(...) service in create_clusterd_service. That function maps enable_unified_cluster onto the service, but other parameters that shape the replica process do not reach it. For example, enable_timely_zero_copy has no effect because Clusterd hardcodes its timely config.

Helpers

  • self.n() - Returns 10^SCALE (default SCALE=6 → 1,000,000)
  • self.table_ten() / self.view_ten() - Creates table/view with values 0-9
  • self.unique_values() - SQL expression generating N unique values via cartesian product
  • self.join() - SQL FROM clause for cartesian product joins
  • self.keyschema() / self.schema() - Kafka schema helpers

Tips

  • Aim for ~1 second query time. Too fast = noise; too slow = Unbearably slow CI.
  • Test td fragments locally with standalone testdrive before running the full benchmark.
  • Use SCALE to control data volume: SCALE = 5 → 100K rows.
  • Use FIXED_SCALE = True if --scale should not affect your scenario. This is usually done when a scenario doesn't scale well, add an explanation.
  • Use RELATIVE_THRESHOLD to customize regression sensitivity per scena
Полный SKILL.md на GitHub

Установить mz-benchmark в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл mz-benchmark?

Add/modify/debug Materialize perf benchmark scenarios. Three frameworks: Feature Benchmark (single-op micro), Scalability Test (SQL throughput under concurrency), Parallel Benchmark (sustained latency via scenarios.py). Trigger: "benchmark", "feature benchmark", "scalability test", "parallel benchmark", "performance regression", "micro-benchmark", "TPS", "latency test", or edits in feature_benchmark/scenarios/, scalability/workload/workloads/, parallel_benchmark/scenarios.py. Note: measurement, not panic-stress (see mz-parallel-workload).

Как установить скилл mz-benchmark?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mz-benchmark запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить mz-benchmark с