9b9dc9590258144d7b7f17d1ecafb674d2d86956 braney Wed Sep 2 13:26:40 2026 -0700 pngLevelBench: sweep the row filter as well as the level, refs #38109 The filter and the level interact, and #38107 picked the filter at the default level only, so measuring one with the other pinned answers half a question. pngLevelBench now takes -filters and -baseFilter, its -tab output carries a filter column, and everything is compared against the pair the browser ships, up at level 6. levelReport.py reads the new column and still accepts rows written before it existed. Two scripts around it grew what a second, larger corpus needed. pickUrls.py takes --seed and --exclude, so a later sample does not repeat an earlier one. render.sh takes its arguments rather than a hardcoded directory, and renders several at once; six in parallel is about seven a second against a ticket sandbox, against one every eight seconds one at a time, and it changes nothing that is measured, since the encode is timed offline afterwards. diff --git src/hg/oneShot/pngLevelBench/render.sh src/hg/oneShot/pngLevelBench/render.sh index d625996baf5..fe8dbf4e0a0 100755 --- src/hg/oneShot/pngLevelBench/render.sh +++ src/hg/oneShot/pngLevelBench/render.sh @@ -1,15 +1,35 @@ #!/bin/bash -# render each corpus URL against the parked hgTracks and keep the png -S="$1"; PORT=48088; i=0 -: > $S/renderLog.tsv -while IFS=$'\t' read -r count query; do - i=$((i+1)) - out=$(printf "%s/corpus/%04d.png" "$S" "$i") +# render each corpus URL against a parked hgTracks and keep the png. +# +# render.sh urlFile outDir port [jobs] +# +# urlFile is the output of pickUrls.py, count and query string per line. The +# pngs land in outDir as 0001.png and so on, and outDir/renderLog.tsv records +# the http code, the mime type, the size and the query for every one of them. +# A response that is not a png is deleted; an error page is not a track image. +# +# hgRenderTracks returns the image itself rather than a page. The explicit +# pix= matters: without it the first hit returns addPixAndReloadPage() and no +# track is ever drawn. +set -u +urlFile="$1"; outDir="$2"; port="$3"; jobs="${4:-1}" +mkdir -p "$outDir" +log="$outDir/renderLog.tsv" +: > "$log" + +render() { + i="$1"; count="$2"; query="$3" + out=$(printf "%s/%04d.png" "$outDir" "$i") code=$(curl -s --max-time 90 -o "$out" -w "%{http_code}" \ - "http://127.0.0.1:$PORT/cgi-bin/hgRenderTracks?${query}&pix=1100") + "http://127.0.0.1:$port/cgi-bin/hgRenderTracks?${query}&pix=1100") type=$(file -b --mime-type "$out" 2>/dev/null) size=$(stat -c %s "$out" 2>/dev/null) - printf "%d\t%s\t%s\t%s\t%s\t%s\n" "$i" "$count" "$code" "$type" "$size" "$query" >> $S/renderLog.tsv - if [ "$type" != "image/png" ]; then rm -f "$out"; fi -done < $S/corpusUrls.tsv -echo "renders done" > $S/render.done + printf "%d\t%s\t%s\t%s\t%s\t%s\n" "$i" "$count" "$code" "$type" "$size" "$query" >> "$log" + [ "$type" = "image/png" ] || rm -f "$out" +} +export -f render +export outDir port log + +nl -ba -w1 -s$'\t' "$urlFile" \ + | xargs -d'\n' -n1 -P "$jobs" bash -c 'IFS=$'"'"'\t'"'"' read -r i count query <<< "$0"; render "$i" "$count" "$query"' +echo "$(grep -c . "$log") renders, $(ls "$outDir"/*.png 2>/dev/null | wc -l) pngs kept"