Introducing a new way to review your PRs.

Read the announcement

reflex-dev / xy

Ultra-fast and customizable Python charts

View on GitHub

20 documents · Updated Nov 18, 2026

docs / performance-benchmarks

Performance benchmarks and regression analysis

The benchmark system measures chart speed, scale, user response, and output cost under named workloads. It runs host and browser launch paths, captures the conditions that affect each result, compares like-for-like baselines, and verifies that regression reports contain enough evidence to trust their claims.

Benchmark scope

Performance questions

The suite separates performance questions because one timing cannot describe the full chart experience. It measures chart construction, export to pixels, browser readiness, interaction response, memory, payload size, and workflow behavior as distinct evidence.

QuestionEvidence
How fast does a chart produce an image?Build time, render time, total time, output size, and a non-blank image check
How does work scale?Workload sizes, repeated summaries, memory, time limits, and explicit status rows
Does a chart remain usable?First paint, complete stable view, frame timing, dropped frames, and settle time
Do common workflows regress?Input, streaming, range, export, dashboard, and transport measurements
Can the result support a claim?Environment data, stable category identity, mode labels, and correctness evidence

The steady-state xy.pyplot versus Matplotlib harness adds a direct chart-to-PNG comparison. It uses the same prepared arrays and Matplotlib-style calls for both libraries, then treats the full build-through-compressed-PNG time as the fair headline measure. Build and export timings remain separate because xy.pyplot can defer work until export.

References: benchmarks/bench_pyplot_vs_matplotlib.py• L1-24 benchmarks/bench_pyplot_vs_matplotlib.py• L110-121 benchmarks/bench_pyplot_vs_matplotlib.py• L474-492

Benchmark categories

Benchmark categories are stable product questions. A category links a workload to the behavior it protects and lets reports compare runs even when the wording or case details change.

The broad category groups are:

  • Startup and footprint: small-data startup, import time, and installed size.
  • Data scale: scatter, line, time-series, density, and drilldown workloads.
  • Chart breadth and workflows: 2D chart families, input, streaming, range, export, and transport.
  • User experience: interaction response and multi-chart dashboards.
  • Delivery cost: payload and export size.

Each report carries the complete category registry and the categories tracked by that run. This makes a narrow report visibly narrow instead of implying coverage of the full product.

References: benchmarks/categories.py• L1-5 benchmarks/categories.py• L11-147 benchmarks/bench_pyplot_vs_matplotlib.py• L57-59 benchmarks/bench_pyplot_vs_matplotlib.py• L477-482

Launch harnesses

Launch sweep

The launch sweep measures a fixed scatter workload across increasing row counts and library arms. It keeps static image work separate from interactive browser work, repeats runs in fresh processes, and preserves raw rows before it creates summaries.

The same seeded input feeds each arm. Data creation is outside the chart timer, while source memory remains part of the process peak. A failed or timed-out size stays in the report so the size ladder does not hide the limit.

flowchart LR
    A[Seeded input] --> B[Fresh host process]
    B --> C{Launch contract}
    C --> D[Static image]
    C --> E[Interactive artifact]
    E --> F[Fresh headless browser]
    D --> G[Validated pixels and host peak]
    F --> H[Ready time, pixels, renderer, browser peak]
    G --> I[Raw report row]
    H --> I
    I --> J[Repeated summary]

References: benchmarks/bench_launch_scatter.py• L1-20 benchmarks/bench_launch_scatter.py• L23-58 benchmarks/bench_launch_scatter.py• L61-95

Static launch path

The static path measures the time to produce a fixed-size PNG. It validates image dimensions and non-blank pixels so a fast empty image cannot count as a successful render. The result describes chart-to-image work and does not include browser startup or interactive behavior.

The steady-state pyplot comparison uses the same principle for several chart families. Its smoke, standard, and huge profiles vary line, scatter, histogram, bar, mesh, and contour work while holding the final PNG target constant. XY rows disclose the render tier used, so direct drawing and screen-bounded aggregation are not treated as the same workload.

References: benchmarks/_launch_static.py• L1-30 benchmarks/_launch_static.py• L43-105 benchmarks/bench_pyplot_vs_matplotlib.py• L185-236 benchmarks/bench_pyplot_vs_matplotlib.py• L443-462

Interactive launch path

The interactive path measures the time from a ready host-side chart description to a chart-ready browser surface. A fresh headless Chrome instance loads the artifact and reports readiness, renderer, non-blank pixels, JavaScript heap, and browser memory.

XY may use a density or other screen-bounded tier for its default overview. An exact arm keeps one marker per source row. These modes are explicit because a faster bounded overview does not prove faster exact-marker rendering.

References: benchmarks/_launch_interactive.py• L1-8 benchmarks/_launch_interactive.py• L141-209 benchmarks/_launch_interactive.py• L309-415 benchmarks/bench_pyplot_vs_matplotlib.py• L136-146

Host-backed launch path

Some chart systems keep part of the render work in a live host process. The WebAgg path starts that host, waits for its HTTP endpoint, opens the page in Chrome, and checks the canvas. Its first-render result therefore covers both host figure setup and browser readiness.

Host and browser memory stay in separate pools. This shows whether a limit comes from data preparation or from page and graphics resources. The UX harness applies the same separation to XY, WebAgg, and Datashader hosts.

References: benchmarks/_launch_webagg.py• L44-76 benchmarks/_launch_webagg.py• L157-327 benchmarks/bench_ux.py• L71-99 benchmarks/bench_ux.py• L684-787

Run conditions and comparison

Environment capture

Every machine-readable report records the context needed to repeat or qualify its numbers. The record includes generation time, Python and operating-system details, CPU count, package and executable versions, backend, browser renderer, and source revision state.

The cross-library CI context uses direct dependency pins in benchmarks/requirements-ci.in and a resolved graph in benchmarks/requirements-ci.lock. The current direct set includes NumPy, Matplotlib, Plotly, Bokeh, Datashader, export tools, and process metrics. The lock targets Python 3.12 on x86_64-unknown-linux-gnu; a lock refresh changes the measurement context even when benchmark code does not change.

The launch baselines use a separate Python 3.14 environment for the macos-arm64-m5-pro host. Both the xy-0.1.0 and xy-main-2026-07-26 baseline environments pin the same launch dependencies and resolve them in their own uv.lock files. This makes the versioned baseline directories comparable records rather than interchangeable install recipes.

References: benchmarks/environment.py• L1-7 benchmarks/environment.py• L41-90 benchmarks/environment.py• L111-146 benchmarks/requirements-ci.in• L1-22 benchmarks/requirements-ci.lock• L1-7 benchmarks/…/pyproject.toml• L1-19 benchmarks/…/pyproject.toml• L1-19

Baseline comparison

Baselines are versioned measurements tied to a host, renderer, source revision, and dependency set. A new run should use a new baseline record instead of replacing an older result. Hardware GPU and SwiftShader software-GPU rows stay in separate groups because their frame timings answer different questions.

The comparison workflow can run library arms in separate jobs and merge their partial reports. The merge accepts reports only when their schema, size ladder, budget, category registry, tracked categories, and timing settings agree. It uses the environment from the partial report that contains XY, so a competitor-only report cannot become the canonical context by artifact order.

Read a change only after the workload, rendering mode, browser renderer, dependency pins, source revision, and measurement scope match. A changed lock file or host is a new measurement context. It is not, by itself, a product regression.

References: benchmarks/README.md• L1-28 benchmarks/README.md• L67-79 benchmarks/README.md• L407-419 scripts/merge_benchmark_reports.py• L25-98 benchmarks/…/uv.lock• L1-8 benchmarks/…/uv.lock• L1-8

User-experience metrics

Correct and stable rendering

The UX harness marks a chart complete only when the view is correct and stable. Correctness checks the expected data view and planted sentinel points. Stability requires the drawing surface to stay unchanged for a run of frames, which avoids counting an early or stale frame as completion.

Load results keep first_frame_ms separate from visible_complete_ms. The second value is the user-facing completion point and accounts for progressive renderers that paint before the full view is ready.

References: benchmarks/_ux_probe.py• L1-17 benchmarks/_ux_probe.py• L203-245 benchmarks/_ux_probe.py• L248-264

Gesture response

The gesture phase replays input on a fixed wall-clock schedule. It does not wait for each frame, so a slow chart cannot receive an easier input stream. The report records frame interval percentiles, maximum interval, achieved frame rate, dropped-frame percentage, and gesture span.

After the last input, the settle phase waits for a smaller correct view and a stable final surface. It reports settle time and the direct zoom_to_final_ms span. This span stays separate from frame p95 so the last frame is not counted twice.

References: benchmarks/_ux_probe.py• L266-345 benchmarks/bench_ux.py• L940-969 benchmarks/README.md• L221-246

UX evidence

The JSON report is the source for measurement claims. Screenshots preserve the visible-complete and settle-complete frames. Per-arm recordings and a shared-clock grid support visual review of the load race.

Dashboard runs extend the UX view to chart setup, navigation, scrolling, JavaScript heap, long tasks, shader activity, and context loss or restoration. Host and browser peak memory remain part of the evidence because a page can fail from either side of the host-browser boundary.

References: benchmarks/bench_ux.py• L407-430 benchmarks/bench_ux.py• L538-609 scripts/verify_benchmark_report.py• L1505-1715

Regression-report verification

Report contract

Benchmark JSON uses schema version 2 and declares its report kind or provides enough fields for the verifier to identify it. Verification first checks shared environment and category data, then checks the shape and meaning of the selected report family.

The contract checks stable category IDs, unique row identities, known statuses, finite values, matching size ladders, required libraries, rendering modes, output targets, and correctness results. It also checks derived claims such as the largest row within a time budget and the largest loss-free dashboard size.

References: scripts/verify_benchmark_report.py• L19-35 scripts/verify_benchmark_report.py• L202-279 scripts/verify_benchmark_report.py• L338-379 scripts/verify_benchmark_report.py• L382-505

Regression gates

Each report family protects a different product boundary. Native and workflow reports require the native backend. Interaction reports require their declared scenarios, timing budgets, visual budgets, and successful interaction evidence. Dashboard reports require attempted chart counts and consistent chart, shader, context, and blank-state telemetry.

Verification is a publication gate rather than a substitute for analysis. A valid report can still show slower work, so engineers must compare matching rows and conditions. A run is not publishable when it drops environment metadata, category links, failed rows, or the oracle that proves what was rendered.

References: scripts/verify_benchmark_report.py• L347-354 scripts/verify_benchmark_report.py• L1261-1433 scripts/verify_benchmark_report.py• L1505-1715 scripts/verify_benchmark_report.py• L2012-2084

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep category IDs, tracked-category lists, and report row links aligned when a workload is renamed or split.
  • Keep baseline host, Python version, dependency lock, browser renderer, and measurement scope aligned before comparing numbers.
  • Keep launch modes and correctness oracles explicit when a renderer changes from direct markers to density, sampling, or decimation.
  • Keep derived ceilings and skipped or failed rows consistent with the raw size ladder after changing timeouts or budgets.
  • Keep UX timing phases separate when changing gesture cadence, stability rules, sentinel checks, or evidence capture.
  • Keep partial-report merge keys and expected library order aligned when changing the CI job split.
  • Update report validation when a new report kind, category, status, or required scenario becomes part of the performance contract.

Important failure modes

TriggerConsequenceGuard
A dependency lock changes but the baseline context is treated as unchangedA dependency effect can look like a product regressionRecord the lock-backed environment and compare with the matching dependency set
Hardware GPU and SwiftShader rows are mixedFrame timings look like a product change when only the renderer changedKeep browser renderer in the environment and baselines in separate groups
A progressive chart stops at first paintThe report understates the time until all data is visibleRequire correct pixels and repeated stable frames
A density result is read as exact-marker scalingDifferent rendering work is compared as if it were equalRequire explicit mode, tier, target, and oracle fields
A library times out at one size and larger rows vanishThe published ceiling appears higher than the evidence supportsPreserve larger sizes as skipped or not-attempted rows
A partial report uses different sizes or categoriesIncompatible experiments are mergedReject metadata disagreement during merge
Environment or category metadata is missingThe result cannot be reproduced or traced to a product questionRequire the schema-v2 environment and category blocks
Dashboard telemetry disagrees with chart IDs or context eventsA partial dashboard can be labeled completeRecompute counts, statuses, and context relationships during verification

Key files

FileWhy to read it
benchmarks/categories.pyDefines the stable product questions and tracked metrics.
benchmarks/bench_pyplot_vs_matplotlib.pyShows a matched host-side PNG comparison, profiles, render-tier disclosure, and speedup claims.
benchmarks/bench_launch_scatter.pyShows how repeated static and interactive launch rows become a report.
benchmarks/_launch_interactive.pyShows the browser launch contract and memory pools.
benchmarks/_launch_static.pyShows the validated chart-to-image contract.
benchmarks/_launch_webagg.pyShows the host server plus browser launch contract.
benchmarks/bench_ux.pyCoordinates hosts, browser arms, recordings, and UX rows.
benchmarks/_ux_probe.pyDefines correct and stable completion plus gesture metrics.
benchmarks/environment.pyDefines the shared run context used to qualify comparisons.
benchmarks/requirements-ci.inDefines direct dependency pins for cross-library CI measurements.
benchmarks/requirements-ci.lockRecords the resolved CI dependency graph and target platform.
benchmarks/…/pyproject.tomlDefines the versioned macOS ARM launch baseline environment.
benchmarks/…/pyproject.tomlDefines the dated main-line launch baseline environment.
scripts/merge_benchmark_reports.pyCombines independent library reports without losing experiment identity.
scripts/verify_benchmark_report.pyEnforces report shape, row meaning, oracles, budgets, and derived ceilings.
benchmarks/README.mdProvides the runbook, baseline rules, interpretation limits, and publication guidance.