Repository navigation
app/: fingerprint new images 8 at a time off the runtime's threads; a finished render wakes only the builds waiting on it (incident 4 Dec 2026) - #171
Merged
Conversation
…me's threads and written back in batches; a finished render wakes only the builds waiting on it (incident 4 Dec 2026)
ndbroadbent
force-pushed
the
app-fast-fingerprints
branch
from
December 4, 2026 05:42
39be2e0 to
21e4979
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Incident fix: builds stuck in processing behind one slow
builds.processrun.Incident 4 Dec 2026
fill_image_fingerprintsdownloaded each new image, then decoded and fingerprinted it, one at a time on the async runtime's thread. Production has a single worker, so one 6m42s build (project 3 build app/: the parity stack for cutover (sc-8900): staff pages, GitHub webhook, live transport, forge sync, security headers, the React app's pages, the image and CI build #87: 3,702 snapshots, 3,634 images; an earlier run took 3m51s) held up everything else. Separately, every finished render dispatchedProcessBuildfor every processing build in its project, about 3 a second per build. Those jobs are debounced, so this was noise, not load.builds_processing0 by about 05:10)./statusoldest_processing_secondsexisted. One is being added; the queue-depth field and its alerts are sc-9145.What changed
domain::blobs::fingerprint_files/image_infos: new image files are downloadedVISUALCI_FINGERPRINT_CONCURRENCYat a time (default 8, a new "Build processing" config section), withbuffer_unorderedin the calling task. Nothing is spawned that touches the database, the cache orlaravel::now(). Each file is decoded and fingerprinted inspawn_blocking, which receives only the bytes. The results are written back with oneUPDATE blobs … FROM (VALUES …)per 5,000 rows, not oneupdate!per blob. A fingerprint already on a row is kept; only a missing size is added. Each file that can't be read logs a warning. Its snapshots fail with the same message as before ("the image couldn't be read: : …").fill_image_fingerprintsuses this.image_info(compare's per-snapshot path) now goes through the same code, so its decode also runs off the runtime. With the runtime thread free, the processing lock's heartbeat keeps renewing during long fills.renders::wake_waitingdispatchesProcessBuildonly for:s.render_id);redraw_basecase: a base's PDF drawn again with the head's renderer settings.Head documents always have their
render_idset before a build waits (queue_render), so no other build can be waiting on the render.Per-phase timing log for each processing run:
processed a buildwithfingerprints_ms,compare_ms,finish_ms,total_msandsnapshots.Expected time for a 3,600-image build
The old path took about 110 ms per new image, in sequence (6m42s / 3,634). Eight downloads at a time, with decoding on the blocking pool, should bring the fingerprint phase to about 3,634 / 8 × 110 ms ≈ 50 s. The worker's cores and R2 latency set the real figure. Fingerprinting stays ahead of comparing because comparison matches on the fingerprints (exact baseline matches, known-by-hash files in later builds), so it can't be split into a step after comparison. The new timing line will show the real split on the next big build.
The 202 blobs with a NULL
pixel_fingerprint(builds 625, 639, 642)Only the server's own decode (
image_info) ever setspixel_fingerprint. These blobs are NULL by design:pdf_fingerprintfrom the renderer);failed, which used to happen silently and is now logged).A completed build runs every non-failed image snapshot through
compare→snapshot_pages→image_info, which fills the blob, and a fill cut short is redone on the next run because the snapshot'ssource_fingerprintis still empty. So a NULL image blob in a completed build means its snapshot failed, or its group was sourced from another build. This query confirms which applies:A client-sent fingerprint is deliberately not copied to the shared blob row, because blobs are global across organizations.
Tests (app/tests/fingerprints.rs)
three_hundred_new_images_are_fingerprinted_while_requests_still_answer: 300 new images sent by hash. While the build processes inline, aGET /upevery 20 ms answers in under 1 s. Every blob gets the right fingerprint, width and height, every snapshot isaddedwith its fingerprint, and the whole test runs in under 30 s.fingerprinting_downloads_no_more_files_at_once_than_its_concurrency: 40 slow fake downloads (100 ms each) at concurrency 8. At most 8 run at once, the run takes under 2 s, and the fingerprints are correct.fingerprinting_decodes_off_the_runtime_thread: on a one-thread runtime, a ticker runs while 3000×3000 PNGs are decoded. It never stalls for even half of one decode.a_finished_render_wakes_only_the_processing_builds_that_wait_on_it: counts theProcessBuildjobs queued. They go to the build drawn by the render and the build waiting on a redraw of its file, and not to an unrelated processing build or a completed one.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.