Repository navigation
Fix wasm allocation, add regression tests for benchmark times for all artifacts - #60
Merged
Merged
Conversation
- Introduced caching for Mermaid SVG outputs to optimize rendering performance. - Added support for multiple allocators: page allocator, arena allocator, and fixed buffer allocator. - Updated rendering functions to utilize the new caching mechanism and allocators. - Implemented a function to flush the Mermaid cache. - Modified the `alloc_buf` and `free_buf` functions to use the page allocator. - Enhanced the CI configuration to include WASM build checks. - Created a script to set up GitHub branch protection rules requiring CI checks.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the project’s performance benchmarking and WASM demo/runtime by adding a mermaid-heavy benchmark fixture, expanding CI with standalone WASM + benchmark regression checks, and refactoring the WASM renderer to expose multiple entrypoints/allocators with a mermaid SVG cache.
Changes:
- Added a committed mermaid-heavy benchmark input and extended the
nix run .#benchflow to publish a dedicated results table for it. - Added CI jobs for a standalone WASM build check and a release-vs-current benchmark regression gate.
- Refactored the WASM demo/entrypoints to support multiple allocator modes and richer in-browser benchmarking/diagnostics UI.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/setup-branch-rules.sh |
Adds a script to configure branch rulesets requiring CI checks (with some mismatches between comments/intended scope vs current ruleset JSON). |
flake.nix |
Adds a WASM flake check and extends the benchmark app to run and publish mermaid-heavy results. |
examples/wasm/zigmark-wasm.zig |
Introduces multiple WASM render entrypoints (arena/FBA/no-mermaid/parse-only) plus a small mermaid SVG cache. |
examples/wasm/index.html |
Adds a benchmark overlay, presets, and JS-side mermaid timing comparison (with an async update race that should be guarded). |
build.zig |
Changes default WASM optimize mode to ReleaseFast and exports new WASM symbols (help text needs updating). |
bench/input-mermaid.md |
Adds a benchmark fixture containing multiple mermaid blocks plus representative GFM content. |
.github/workflows/ci.yml |
Adds standalone wasm and bench-regression jobs to make those checks independently required. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+4
to
+6
| # Creates (or updates) a ruleset named "main-branch-protection" that requires | ||
| # all four CI checks to pass before merging into main or zig-* branches. | ||
| # |
Comment on lines
+41
to
+45
| conditions: { | ||
| ref_name: { | ||
| include: ["~ALL"], | ||
| exclude: [] | ||
| } |
| @@ -293,7 +293,7 @@ pub fn build(b: *std.Build) void { | |||
| std.builtin.OptimizeMode, | |||
| "wasm-optimize", | |||
| "Optimization for WASM target (default: ReleaseSmall)", | |||
| const rendererSelect = document.getElementById('renderer-select'); | ||
| const copyOutputBtn = document.getElementById('copy-output'); | ||
|
|
||
| let debounce = null; |
Comment on lines
+331
to
333
| async function update() { | ||
| const md = editor.value; | ||
| const renderer = rendererSelect.value; |
sc2ben
self-requested a review
June 6, 2026 03:43
…te function in HTML example
sc2ben
approved these changes
Jun 6, 2026
sc2ben
left a comment
Member
There was a problem hiding this comment.
Adding rulesets to repo for IaC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant improvements to benchmarking, WASM build configuration, and the renderer implementation for the project. The changes add a mermaid-heavy benchmark input, expand the benchmarking suite to cover mermaid diagrams, optimize and expose multiple WASM render entrypoints with different allocators and caching strategies, and improve CI and Nix flake integration for WASM builds and regression checks.
Benchmarking and Input Improvements:
bench/input-mermaid.mdcontaining multiple mermaid diagram blocks and representative GFM content to better evaluate parser and renderer performance on diagram-heavy documents.flake.nixto run a separate set of benchmarks using the new mermaid-heavy input, and to generate a dedicated results table for these runs. [1] [2] [3] [4]WASM Build and CI Enhancements:
.github/workflows/ci.ymlso that WASM builds appear as a distinct required check in GitHub branch rules and are independently verifiable. Also added a benchmark regression job that compares the current build against the last release usinghyperfine.flake.nixto add a WASM build check (checks.wasm) to the flake outputs, ensuring WASM module production is verified in CI.Renderer and Allocator Optimizations (WASM):
examples/wasm/zigmark-wasm.zigto provide multiple render entrypoints:render_html_arena(persistent arena allocator for fast repeated renders)render_html_fba(fixed buffer allocator for zero-syscall rendering)render_html_nomermaid(renders without mermaid for overhead measurement)flush_mermaid_cache(clears the SVG cache)parse_only(isolates parse time for benchmarks)Build Configuration:
ReleaseSmalltoReleaseFastfor improved performance in benchmarks.These changes collectively enable more accurate, representative benchmarking (especially for mermaid-heavy documents), improve the reliability and reproducibility of WASM builds in CI, and provide optimized rendering pathways for different usage scenarios.