7007b23dcc178ac0d6a64642ecd5a1060c6f6a40 braney Thu Aug 27 13:47:54 2026 -0700 hgTracks: measure how long the track image takes to reach the reader, refs #38109 We cannot choose a png compression level without knowing the reader's connection speed. Our own logs will not tell us: apache stops timing once the kernel has the bytes, so its duration field stays near two milliseconds whether the image is 20 KB or 500 KB. The reader's browser does know. It keeps a timing record for every image it loads, holding the bytes taken off the wire and the time waited. This reads that record for the track image and reports the numbers on the query string of DOT.gif, a 43 byte image that already sits in htdocs/images. No process starts, nothing touches the cart, and the client address, the time and the numbers all land in the same access log we already archive. New hg.conf setting pngTimingSampleRate. It is the N in one page load in N. Zero, or the setting left out, turns the whole thing off, which is the default. The report carries three numbers. ts is the bytes off the wire, d is the whole fetch, and x is only the time the bytes were arriving. x is the denominator for throughput, d is what the reader actually waited. diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index 4829c595b97..b80c0785cb8 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -10485,30 +10485,36 @@ cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); cartSaveSession(cart); puts("</FORM>"); // put the track download interface behind hg.conf control if (cfgOptionBooleanDefault("showMouseovers", FALSE)) jsInline("var showMouseovers = true;\n"); // if the configure page allows hgc popups tell the javascript about it if (cfgOptionBooleanDefault("canDoHgcInPopUp", TRUE) && cartUsualBoolean(cart, "doHgcInPopUp", TRUE)) jsInline("var doHgcInPopUp = true;\n"); if (cfgOptionBooleanDefault("greyBarIcons", TRUE)) jsInline("var greyBarIcons = true;\n"); +// measure how long the track image takes to reach the reader, on one page load +// in pngTimingSampleRate. Zero, or the setting left out, turns it off. +int pngTimingSampleRate = atoi(cfgOptionDefault("pngTimingSampleRate", "0")); +if (pngTimingSampleRate > 0) + jsInlineF("var pngTimingSampleRate = %d;\n", pngTimingSampleRate); + // TODO GALT nothing to do here. pruneRedundantCartVis(trackList); if (measureTiming) measureTime("Done with trackForm"); } static void toggleRevCmplDisp() /* toggle the reverse complement display mode */ { // forces complement bases to match display revCmplDisp = !revCmplDisp; cartSetBooleanDb(cart, database, REV_CMPL_DISP, revCmplDisp); cartSetBooleanDb(cart, database, COMPLEMENT_BASES_VAR, revCmplDisp); }