experimental/air: warm snapshot cache + parallel gzip for plain_tar - #6560
Closed
ben-hansen-db wants to merge 1 commit into
Closed
experimental/air: warm snapshot cache + parallel gzip for plain_tar#6560ben-hansen-db wants to merge 1 commit into
ben-hansen-db wants to merge 1 commit into
Conversation
The plain_tar snapshot path (dirty working tree / no git ref) re-walked, re-tarred and re-gzipped the whole tree on every submission. Add a local warm cache keyed by (repo, config, include_paths) under $TMPDIR/databricks/.air/<key>: an uncompressed snapshot.tar plus a manifest of each file's size+mtime and byte range. Later runs copy unchanged members verbatim from the warm tar and re-read only the changed files; gzip is parallelised with klauspost/pgzip (drop-in, ~18x faster on a 470 MiB tar). --no-cache bypasses the cache and re-packs from scratch. The cache engages only above 64 MiB, where a plain re-pack is slow. Local packaging latency only (file walk + tar + gzip; upload and API round trips are not measured and are unchanged by this PR): research (7.4k files): before 2456 ms -> warm hit 557 ms research+js+spark (27.8k/476MB): before 8525 ms -> warm hit 934 ms whole universe (534k files/~4GB): before ~2-3 min -> warm hit 6.6 s Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
Author
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.
Summary
The
air runplain_tar snapshot path — used when the working tree is dirty or has no git ref, i.e. the normal iterate-and-resubmit dev loop — re-walked, re-tarred, and re-gzipped the entire source tree on every submission. For a large tree (e.g.universewithinclude_paths) that is seconds to minutes of pure packaging on every run.This adds a local warm cache for that path plus parallel gzip:
(repo path, config path, include_paths)under$TMPDIR/databricks/.air/<sha256>/: an uncompressedsnapshot.tar+ amanifest.jsonrecording each file's size, mtime (ns), and byte-range in the tar. On the next run we stat the current file set; unchanged members are copied verbatim from the warm tar (no disk re-read), only changed/new files are re-read, and deletions drop out. Change detection is size+mtime — the same fingerprint DABs file-sync uses. Keyed so different repos / configs / include-sets never collide.klauspost/pgzip(MIT), a drop-in forcompress/gzip. gzip over the whole tar is the dominant packaging cost and is paid on every run (even a no-change hit re-gzips); pgzip spreads it across cores — ~18× faster on a 470 MiB tar. Level is BestSpeed since upload size doesn't matter here, only latency.--no-cachebypasses the cache and re-packs from scratch (the old shell-tarpath).Results — local packaging only
These are packaging latency (git file walk + tar + gzip), measured by calling the packaging functions directly. They do NOT include the workspace upload or API / run-creation round trips. For
plain_tarthe upload is unchanged by this PR — it still uploads the full compressed tarball each run (the upload name is timestamped, not content-addressed).Measured on
universe(32-core host, warm page cache):Isolated gzip step (470 MiB tar):
compress/gzip2,123 ms →pgzip119 ms.Known limitations / follow-ups (not in this PR)
git ls-files+ ~534kos.Lstatcalls (36k of them index entries not present in this sparse checkout). Parallelizing the stat pass and/or skipping skip-worktree entries would cut this..tar.gz) would make a rebuild O(changed bytes).snapshot.tar.tmppath — needs a unique temp name + lock.$TMPDIRper key indefinitely..nextchangesfragment yet (experimental command) — add if we want a changelog entry.Validation
gzip -t, its entry count matches the manifest exactly, extracted content matches source, symlinks are preserved, and index-but-not-checked-out files are correctly skipped (sparse checkout).snapshot_cache_test.go; theinternal/buildlicense test passes for the newpgzipdep (annotated// MITingo.mod+NOTICE).This pull request and its description were written by Isaac.