Skip to content

feat: report each encoder's peak memory - #60

Merged
nucliweb merged 1 commit into
mainfrom
feat/encode-memory
Oct 20, 2026
Merged

nucliweb merged 1 commit into
mainfrom
feat/encode-memory

Conversation

@nucliweb

Copy link
Copy Markdown
Owner

What

From the ROADMAP's "Encode memory" idea (it comes from image-codec-bench): memory is part of an encoder's cost, and matters where many images are encoded in parallel.

  • exec.js: /usr/bin/time runs with -f "real %e\nuser %U\nsys %S\nmaxrss %M" when it is GNU time (detected by --version), -l -p on macOS and the BSDs, and -p elsewhere. parseTimeOutput returns peakBytes from GNU's maxrss (KB) or BSD's "maximum resident set size" (bytes), null when absent.
  • Pipeline: the peak of the single encode at the target; with --time-runs, the largest of the runs.
  • Output: a memory column in the table (MB), encode_peak_rss_bytes in both CSVs, and memory in the HTML stats panel. CSV change: the new column sits before error, which stays last; readers by column position need updating (readers by header name, including the regression gate, are unaffected).
  • Docs: the Output section's example table and a paragraph on memory; the ROADMAP item is removed.

Verification

  • node --test: 99 pass, including GNU and BSD parsing, the table, CSV and HTML.
  • Integration: 15 pass on macOS (BSD time), 17 pass inside ghcr.io/nucliweb/image-tools:0.5.0 with this branch mounted (GNU time); the new assertion checks every CSV row carries a positive peak memory.
  • Real runs on cid22-friends.png: macOS gives 4.5–42.3 MB, the image 5.6–48.9 MB across the six codecs; the HTML report shows the figure in headless Chrome.

Every encode already runs under /usr/bin/time, which also reports the peak resident memory: GNU time through a format with %M (kilobytes), BSD time on macOS with -l (bytes). The comparison table gains a memory column, both CSVs an encode_peak_rss_bytes column before error, and the HTML report's stats panel the same figure. It is the peak of the single encode at the target, or the largest of the --time-runs encodes, and n/a where /usr/bin/time is missing.
@github-actions

Copy link
Copy Markdown

Codec comparison ✅ no size or quality regression

📥 Download the codec report (unzip and open report.html locally). Available until 2027-01-17, when GitHub deletes the artifact.

Size check
Size regression check (target 90, size tolerance 2.0%, quality tolerance 0.5 ssimulacra2)

  ok         cid22-blossoms.png  JPEG XL  base 105038 → 105038  (+0.00%)  ss2 90.08 → 90.08  (+0.00)
  ok         cid22-blossoms.png  WebP  base 118162 → 118162  (+0.00%)  ss2 76.87 → 76.87  (+0.00)
  ok         cid22-blossoms.png  AVIF  base 128030 → 128030  (+0.00%)  ss2 89.75 → 89.75  (+0.00)
  ok         cid22-blossoms.png  jpegli  base 137045 → 137045  (+0.00%)  ss2 90.11 → 90.11  (+0.00)
  ok         cid22-blossoms.png  mozjpeg  base 164234 → 164234  (+0.00%)  ss2 90.20 → 90.20  (+0.00)
  ok         cid22-blossoms.png  HEIC  base 194761 → 194761  (+0.00%)  ss2 82.22 → 82.22  (+0.00)
  ok         cid22-church.png  JPEG XL  base 61171 → 61171  (+0.00%)  ss2 89.85 → 89.85  (+0.00)
  ok         cid22-church.png  AVIF  base 68127 → 68127  (+0.00%)  ss2 89.73 → 89.73  (+0.00)
  ok         cid22-church.png  HEIC  base 71021 → 71021  (+0.00%)  ss2 90.11 → 90.11  (+0.00)
  ok         cid22-church.png  jpegli  base 78183 → 78183  (+0.00%)  ss2 89.74 → 89.74  (+0.00)
  ok         cid22-church.png  WebP  base 94246 → 94246  (+0.00%)  ss2 88.91 → 88.91  (+0.00)
  ok         cid22-church.png  mozjpeg  base 99280 → 99280  (+0.00%)  ss2 89.89 → 89.89  (+0.00)
  ok         cid22-friends.png  JPEG XL  base 52793 → 52793  (+0.00%)  ss2 89.83 → 89.83  (+0.00)
  ok         cid22-friends.png  AVIF  base 54356 → 54356  (+0.00%)  ss2 89.97 → 89.97  (+0.00)
  ok         cid22-friends.png  jpegli  base 64424 → 64424  (+0.00%)  ss2 89.80 → 89.80  (+0.00)
  ok         cid22-friends.png  HEIC  base 79196 → 79196  (+0.00%)  ss2 90.01 → 90.01  (+0.00)
  ok         cid22-friends.png  WebP  base 87218 → 87218  (+0.00%)  ss2 89.44 → 89.44  (+0.00)
  ok         cid22-friends.png  mozjpeg  base 91561 → 91561  (+0.00%)  ss2 90.25 → 90.25  (+0.00)
  ok         corporate-memphis.png  AVIF  base 19074 → 19074  (+0.00%)  ss2 89.87 → 89.87  (+0.00)
  ok         corporate-memphis.png  JPEG XL  base 44539 → 44539  (+0.00%)  ss2 90.24 → 90.24  (+0.00)
  ok         corporate-memphis.png  WebP  base 46758 → 46758  (+0.00%)  ss2 85.87 → 85.87  (+0.00)
  ok         corporate-memphis.png  HEIC  base 68663 → 68663  (+0.00%)  ss2 88.01 → 88.01  (+0.00)
  ok         corporate-memphis.png  jpegli  base 80411 → 80411  (+0.00%)  ss2 89.92 → 89.92  (+0.00)
  ok         corporate-memphis.png  mozjpeg  base 100129 → 100129  (+0.00%)  ss2 89.62 → 89.62  (+0.00)
  ok         forest-leaves.png  JPEG XL  base 626391 → 626391  (+0.00%)  ss2 89.67 → 89.67  (+0.00)
  ok         forest-leaves.png  HEIC  base 678675 → 678675  (+0.00%)  ss2 89.87 → 89.87  (+0.00)
  ok         forest-leaves.png  jpegli  base 741875 → 741875  (+0.00%)  ss2 89.87 → 89.87  (+0.00)
  ok         forest-leaves.png  WebP  base 753448 → 753448  (+0.00%)  ss2 89.52 → 89.52  (+0.00)
  ok         forest-leaves.png  AVIF  base 824552 → 824552  (+0.00%)  ss2 90.45 → 90.45  (+0.00)
  ok         forest-leaves.png  mozjpeg  base 1119980 → 1119980  (+0.00%)  ss2 89.60 → 89.60  (+0.00)
  ok         pipeline-diagram.png  AVIF  base 62798 → 62798  (+0.00%)  ss2 90.07 → 90.07  (+0.00)
  ok         pipeline-diagram.png  WebP  base 63042 → 63042  (+0.00%)  ss2 73.46 → 73.46  (+0.00)
  ok         pipeline-diagram.png  JPEG XL  base 75252 → 75252  (+0.00%)  ss2 89.83 → 89.83  (+0.00)
  ok         pipeline-diagram.png  HEIC  base 97122 → 97122  (+0.00%)  ss2 73.38 → 73.38  (+0.00)
  ok         pipeline-diagram.png  jpegli  base 113660 → 113660  (+0.00%)  ss2 89.27 → 89.27  (+0.00)
  ok         pipeline-diagram.png  mozjpeg  base 180740 → 180740  (+0.00%)  ss2 89.86 → 89.86  (+0.00)
  ok         report-ui.png  AVIF  base 64121 → 64121  (+0.00%)  ss2 89.82 → 89.82  (+0.00)
  ok         report-ui.png  JPEG XL  base 98049 → 98049  (+0.00%)  ss2 89.61 → 89.61  (+0.00)
  ok         report-ui.png  WebP  base 117598 → 117598  (+0.00%)  ss2 77.40 → 77.40  (+0.00)
  ok         report-ui.png  jpegli  base 169432 → 169432  (+0.00%)  ss2 89.92 → 89.92  (+0.00)
  ok         report-ui.png  HEIC  base 174308 → 174308  (+0.00%)  ss2 83.19 → 83.19  (+0.00)
  ok         report-ui.png  mozjpeg  base 218438 → 218438  (+0.00%)  ss2 90.25 → 90.25  (+0.00)

OK: no size or quality regressions.

@nucliweb
nucliweb merged commit a785aff into main Oct 20, 2026
2 checks passed
@nucliweb
nucliweb deleted the feat/encode-memory branch October 20, 2026 20:53
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