Skip to content

feat: redesign benchmark system with CI integration#7197

Open
teredasites wants to merge 1 commit intomaplibre:mainfrom
teredasites:feat/redesign-benchmarks
Open

feat: redesign benchmark system with CI integration#7197
teredasites wants to merge 1 commit intomaplibre:mainfrom
teredasites:feat/redesign-benchmarks

Conversation

@teredasites
Copy link

/claim #982

Summary

Redesigns the benchmark system to address the issues raised in #982:

Problem

The existing benchmarks require a custom rollup build that tightly couples to internal module structure, making them fragile across version changes. They don't run in CI, produce results that are hard to interpret programmatically, and comparing previous versions requires pre-built artifacts stored on GitHub Pages.

Solution: Two-Tier Architecture

Tier 1: Microbenchmarks (CI, fast)

Pure-computation benchmarks that run via vitest bench on every PR. These test isolated hot paths without needing a browser, WebGL, or network:

  • Polygon subdivision (varying vertex counts and hole complexity)
  • Covering tile computation (mercator + globe, flat + pitched)
  • Filter creation from a representative dataset
  • Style specification validation

Run locally with npm run benchmark-micro.

Tier 2: E2E Benchmarks (CI + manual)

A new CI-oriented headless Chrome runner (run-benchmarks-ci.ts) that:

  • Produces structured JSON output instead of just PDF/visual graphs
  • Supports baseline comparison with configurable regression thresholds
  • Exits non-zero when benchmarks regress beyond the threshold
  • Includes a markdown formatter (format-bench-results.ts) for PR comment posting

Run locally with npm run benchmark-ci.

Production Build Support

A new index-prod.html page runs benchmarks against the standard dist/maplibre-gl.js production build rather than the custom-bundled benchmarks_generated.js. Previous versions are loaded from unpkg CDN, so no per-version build artifacts need to be generated or stored.

What's Preserved

The existing browser-based visual benchmark suite is fully preserved -- the original index.html, rollup config, benchmarks_view.tsx, and all Benchmark subclasses are untouched. The new system coexists alongside it (acceptance criteria #3).

Changes

File Change
vitest.config.bench.ts New vitest config for microbenchmarks
test/bench/benchmarks/computation.bench.ts Microbenchmarks: subdivide, covering tiles, filters, style validation
test/bench/run-benchmarks-ci.ts CI-oriented headless runner with JSON output and regression detection
test/bench/format-bench-results.ts Markdown formatter for baseline comparison results
test/bench/versions/index-prod.html Run benchmarks against production dist + CDN versions
.github/workflows/benchmark.yml CI workflow: microbenchmarks + E2E on every PR
package.json Added benchmark-ci and benchmark-micro scripts
test/bench/README.md Comprehensive documentation of the new architecture
tsconfig.json Exclude new Node.js scripts from browser typecheck
.gitignore Ignore benchmark output artifacts

Acceptance Criteria

  1. Benchmarks run as part of CI -- benchmark.yml workflow runs microbenchmarks and E2E benchmarks on every PR and push to main.
  2. Easy to test previous versions -- index-prod.html loads any published version from unpkg CDN. No need to generate per-version artifacts.
  3. Simpler, coexists with manual benchmarks -- The existing visual benchmark suite is fully preserved. The new tier adds CI coverage without replacing anything.
  4. Design presented -- Two-tier architecture (microbenchmarks + E2E) with production build support, documented in the updated README.

Test plan

  • npm run benchmark-micro runs microbenchmarks successfully via vitest bench
  • npm run start-bench + npm run benchmark-ci produces JSON output
  • npm run benchmark-ci -- --baseline results.json --threshold 10 detects regressions
  • index-prod.html loads correctly and can compare against CDN versions
  • Existing npm run benchmark continues to work unchanged
  • CI workflow validates benchmark execution on PRs

…ild support

Add a two-tier benchmark architecture:

1. Microbenchmarks (vitest bench) - pure computation benchmarks that run
   in CI on every PR without browser/WebGL dependencies. Covers hot paths
   like polygon subdivision, covering tile computation, filter creation,
   and style validation.

2. CI-oriented E2E runner (run-benchmarks-ci.ts) - headless Chrome runner
   that produces structured JSON output with pass/fail semantics based on
   configurable regression thresholds.

Key changes:
- Add vitest.config.bench.ts for microbenchmark configuration
- Add computation.bench.ts with subdivide, covering tiles, filter, and
  style validation benchmarks
- Add run-benchmarks-ci.ts for headless CI execution with JSON output
  and baseline comparison support
- Add format-bench-results.ts for markdown output suitable for PR comments
- Add benchmark.yml GitHub Actions workflow running both tiers on PRs
- Add index-prod.html to run benchmarks against dist/ production builds
  and compare with previous versions from CDN (unpkg)
- Update package.json with benchmark-ci and benchmark-micro scripts
- Update README with comprehensive documentation of the new architecture
- Keep existing browser-based visual benchmark system fully intact

Closes maplibre#982
@HarelM
Copy link
Collaborator

HarelM commented Feb 28, 2026

Was this generated by AI? because it falls to address this issue in so many aspects...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants