385cb594dbd4ff14124a64816d0a649458bff44d
braney
  Wed Sep 2 12:15:29 2026 -0700
pngLevelBench: measure what each png compression level costs and saves, refs #38109

The compression level decision needs two numbers per level: the bytes the track
image grows by, and the encode time it saves.  A reader gains from a lower
level only above B/S, which is a speed, so the two numbers turn each level into
one break-even link speed to compare against the reader throughput the log
reader reports.

The encode matches lib/pngwrite.c exactly, RGBA with the row filter pinned to
UP, and nothing is written to disk, so the time is the encode alone.  The check
that makes an offline measurement stand for what the CGI does is -check: at
level 6, which is what libpng's default resolves to, this has to reproduce the
file hgTracks wrote, byte for byte.  It does, for every image tried.

Also here are the three scripts around it: picking a traffic weighted corpus of
real hgTracks URLs out of an access log, rendering them against a parked
hgTracks, and aggregating the result into per level bytes, ms and break-even
speed.  The README gives the order they run in and the one known weakness, that
a replayed URL renders the trackDb default track set rather than the reader's
own.

diff --git src/hg/oneShot/pngLevelBench/makefile src/hg/oneShot/pngLevelBench/makefile
new file mode 100644
index 00000000000..da0b37c4eac
--- /dev/null
+++ src/hg/oneShot/pngLevelBench/makefile
@@ -0,0 +1,19 @@
+kentSrc = ../../..
+include ../../../inc/common.mk
+
+L += ${PNGLIB} -lm
+MYLIBDIR = ../../../lib/${MACHTYPE}
+MYLIBS = ${MYLIBDIR}/jkweb.a
+
+A = pngLevelBench
+O = pngLevelBench.o
+
+pngLevelBench: ${O} ${MYLIBS}
+	${CC} ${COPT} -o ${DESTDIR}${BINDIR}/${A}${EXE} $O ${MYLIBS} $L
+	${STRIP} ${DESTDIR}${BINDIR}/${A}${EXE}
+
+compile:: ${O}
+	${CC} ${COPT} -o ${A}${EXE} ${O} ${MYLIBS} $L
+
+clean::
+	rm -f ${A}${EXE} ${O}