Skip to content

perf(style_tt): batch @style accumulation instead of per-call rbind - #667

Merged
vincentarelbundock merged 2 commits into
vincentarelbundock:mainfrom
EinMaulwurf:perf/lazy-style-batch
Jul 11, 2026
Merged

perf(style_tt): batch @style accumulation instead of per-call rbind#667
vincentarelbundock merged 2 commits into
vincentarelbundock:mainfrom
EinMaulwurf:perf/lazy-style-batch

Conversation

@EinMaulwurf

@EinMaulwurf EinMaulwurf commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

NOTE: This PR and the code changes are entirely "vibe coded" using GLM-5.2.


style_tt_lazy() previously grew @style with an incremental rbind() on every style_tt() call. That per-call rbind() is O(N^2) in the number of style calls and dominated the lazy-style evaluation phase on tables with many style_tt() calls (e.g. per-cell heat-maps, alternating row backgrounds).

style_tt_lazy() now exposes only the current call's settings frame in @style; build_tt() collects those frames and rbind()s them once at the end of the lazy loop. Output is byte-for-byte identical (verified across 14 fixtures x 4 formats and the full tinytest suite).

End-to-end save_tt() speedup scales with the number of style_tt() calls:

  • heavy (60x12, 165 calls) typst 1.14x / html 1.08x
  • stress (100x15, 473 calls) typst 1.20x / html 1.22x

EinMaulwurf and others added 2 commits July 8, 2026 16:31
style_tt_lazy() previously grew @Style with an incremental rbind() on every
style_tt() call. That per-call rbind() is O(N^2) in the number of style
calls and dominated the lazy-style evaluation phase on tables with many
style_tt() calls (e.g. per-cell heat-maps, alternating row backgrounds).

style_tt_lazy() now exposes only the current call's settings frame in
@Style; build_tt() collects those frames and rbind()s them once at the end
of the lazy loop. Output is byte-for-byte identical (verified across 14
fixtures x 4 formats and the full tinytest suite).

End-to-end save_tt() speedup scales with the number of style_tt() calls:
  heavy (60x12, 165 calls)  typst 1.14x / html 1.08x
  stress (100x15, 473 calls) typst 1.20x / html 1.22x
@vincentarelbundock
vincentarelbundock merged commit a4a1c5c into vincentarelbundock:main Jul 11, 2026
@vincentarelbundock

Copy link
Copy Markdown
Owner

thanks a lot! merged

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