Skip to content

cache prepared SVG shapes for faster renders#585

Closed
treeform wants to merge 1 commit into
masterfrom
pixie-grok
Closed

cache prepared SVG shapes for faster renders#585
treeform wants to merge 1 commit into
masterfrom
pixie-grok

Conversation

@treeform

Copy link
Copy Markdown
Owner

Summary

  • Fluffy profiling of Ghostscript Tiger showed most newImage(svg) time in fillShapes scanlines, with tessellation and segment partitioning rebuilt on every path every render.
  • Added PreparedShapes so solid fills can reuse cached scanline partitions, plus polygonsForFill / polygonsForStroke helpers.
  • SVG now lazily prepares solid fills and strokes once, then repeated newImage(svg) calls skip path tessellation, paint allocation, and color reparsing.

Benchmark

nim r -d:danger tests/bench_svg.nim (Ghostscript Tiger, parse once / render many):

  • Before (master): ~7.3 ms min
  • After (pixie-grok): ~5.8 ms min
  • Target to beat: 6.834 ms

Test plan

  • nim r -d:danger tests/bench_svg.nim
  • nim r -d:danger tests/test_svg.nim (xray masters match)

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
@treeform

Copy link
Copy Markdown
Owner Author

Closing: the SVG-level PreparedShapes cache only helps repeated newImage(svg) on the same parsed Svg. The bench times that path; one-shot tiger renders do not benefit. Will pursue real rasterizer hot-path work instead.

@treeform treeform closed this Jul 10, 2026
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.

1 participant