Skip to content

feat: parallelize sixel and kitty image encoding with cl-concurrent-kit - #14

Merged
takeokunn merged 1 commit into
mainfrom
feat/concurrent-kit-image-parallelism
Aug 5, 2026
Merged

feat: parallelize sixel and kitty image encoding with cl-concurrent-kit#14
takeokunn merged 1 commit into
mainfrom
feat/concurrent-kit-image-parallelism

Conversation

@takeokunn

Copy link
Copy Markdown
Collaborator

Summary

  • format-sixel and ansi-kitty-image accept an optional :executor/:chunk-count, parallelizing color quantization and band/APC-chunk encoding across a caller-owned cl-concurrent-kit:executor when the image is at least 64x64.
  • Default (no :executor) behavior is fully serial and unchanged; output is byte-identical either way, verified across dozens of chunk-count/size combinations including odd, non-power-of-two counts.
  • Fixes scripts/benchmark-hotpaths.lisp, which previously aborted before running any case.

Measured

  • format-sixel: 6.7-6.9x at 256x256/512x512 (both phases parallel; band-only alone only reached 1.5-1.7x due to Amdahl's law on the quantization phase)
  • ansi-kitty-image: 3.7-4.3x at 256x256 up to 2048x2048

Test plan

  • Full run-tests.lisp suite passing, including new byte-identical serial-vs-parallel tests
  • nix flake check: exit 0
  • scripts/benchmark-hotpaths.lisp now runs to completion

Both FORMAT-SIXEL and ANSI-KITTY-IMAGE now accept an optional :EXECUTOR (a
caller-owned CL-CONCURRENT-KIT:EXECUTOR) and :CHUNK-COUNT. When supplied and
WIDTH*HEIGHT clears +SIXEL-PARALLEL-PIXEL-THRESHOLD+ (64x64), color
quantization and the per-band/per-APC-chunk encoding pass run across the
executor's workers instead of the calling thread; otherwise both stay fully
serial, unchanged from before. Output is byte-identical in either mode,
verified against tens of chunk-count/size combinations including
non-power-of-two counts that would surface an uneven-partition bug.

Measured on this host: format-sixel 6.7-6.9x at 256x256/512x512 (both the
color-quantization and band-encoding phases parallelized -- band-only gave
just 1.5-1.7x, since quantization was 43-55% of total runtime and capped the
Amdahl ceiling); ansi-kitty-image 3.7-4.3x at 256x256 up to 2048x2048, where
serial cost reaches 76ms and is worth parallelizing for the first time.

Also fixes scripts/benchmark-hotpaths.lisp, which aborted on its first case
under a stale keyword-argument MAKE-STYLE call, and then (once fixed) on
comparing PLAN-DIFF-LENGTH's ungrouped upper-bound estimate against the
grouped length %WRITE-PREFERRED-DIFF actually renders -- the renderer's
strategy choice was already correct; only the benchmark's own gate compared
the wrong number. The script now runs every case end to end.
@takeokunn
takeokunn force-pushed the feat/concurrent-kit-image-parallelism branch from 1344479 to e23a048 Compare August 5, 2026 16:36
@takeokunn
takeokunn merged commit e23a048 into main Aug 5, 2026
2 of 3 checks passed
@takeokunn
takeokunn deleted the feat/concurrent-kit-image-parallelism branch August 5, 2026 16:59
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