-
Notifications
You must be signed in to change notification settings - Fork 3
feat(scala-sbt): warm-cache plugin command; add ADR-015 #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3b5f8c8
docs(adr): add ADR-015 and migrate scala-sbt off virtiofs caches
razvanz 9d1d6bc
docs(adr-015): correct credential channel reference
razvanz 1124477
docs(adr-015): drop ~/.ssh example; clarify sensitive-data channels
razvanz 0e99054
feat(scala-sbt): warm host caches via bootstrap mount + rsync
razvanz c00789c
docs(adr-015): trim to essentials
razvanz 7313b08
feat(scala-sbt): release bootstrap mounts after warmup
razvanz 5213865
refactor(scala-sbt): warm cache via plugin command, drop virtiofs
razvanz 6e5298a
docs(adr-015): soften from project-wide rule to in-tree policy
razvanz abf9ac2
docs(adr-015): trim further
razvanz 47ebf66
docs(adr-015): present VM snapshotting as possibility, not future work
razvanz c4f5803
docs(readme): refresh scala-sbt section; note cache choice in limitat…
razvanz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # 015: Avoid virtiofs for churning caches | ||
|
|
||
| **Date:** 2026-04-27 | ||
| **Status:** accepted | ||
|
|
||
| ## Problem | ||
|
|
||
| `virtiofsd --cache=auto` accumulates backing-file FDs monotonically. Under churning workloads (`sbt update`, package-manager refreshes), shares pin at `RLIMIT_NOFILE` and surface as `ENFILE` in the guest (#18). Raising the ceiling (PR #20) doesn't change the trajectory. | ||
|
|
||
| ## Decision | ||
|
|
||
| In-tree plugins do not virtiofs-mount churning data — package-manager caches, build-artifact caches, indexer state. Cache I/O lives on `root.img` (persists per workspace) at the tool's default location, or via env-var redirect from a setup script. | ||
|
|
||
| When useful host warm-cache state exists, in-tree plugins deliver it via a host-side **plugin command** invoked from `post-up` — the pattern of `nixbox aws login` and `nixbox claude-code sync-config`. Streams over the existing SSH channel (`tar | nixbox run "tar -x"`); sentinel-guarded. | ||
|
|
||
| Third-party plugins are not bound. Authors who virtiofs-mount churning caches accept the FD cost — any long enough session will exhaust the ceiling. The plugin-command pattern is one alternative, not the only one. | ||
|
|
||
| Use virtiofs only where in-place cross-boundary semantics matter (e.g. source trees). | ||
|
|
||
| ## Consequences | ||
|
|
||
| - `plugins/scala-sbt`: warmup via `nixbox scala-sbt warm-cache`. No virtiofs mounts. | ||
| - Host↔guest cache sharing is one-shot, not live: warmup snapshots host state at first boot, then guest and host diverge. | ||
|
|
||
| ## Possible direction | ||
|
|
||
| VM snapshotting (qcow2 backing or cloud-hypervisor save/restore) could replace the per-workspace warmup with a pre-warmed image. Not committed work — noted as one way this trade-off might be revisited. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Plugin command: nixbox scala-sbt warm-cache | ||
| # One-shot copy of the host's coursier and ivy2 caches into the guest's | ||
| # ~/.cache/coursier and ~/.ivy2. Idempotent — guarded by a sentinel file | ||
| # inside each guest cache dir. Invoked from the plugin's post-up hook so | ||
| # warmup runs automatically once per workspace. | ||
|
|
||
| die() { printf '\r%s\n' "ERROR: $*" >&2; exit 1; } | ||
| log() { printf '\r%s\n' "$*"; } | ||
| log_sub() { printf '\r %s\n' "$*"; } | ||
|
|
||
| warm() { | ||
| local host_src="$1" guest_relpath="$2" name="$3" | ||
| [ -d "$host_src" ] || { log_sub "skip $name: $host_src not found on host"; return 0; } | ||
|
|
||
| if nixbox run "test -f \"\$HOME/$guest_relpath/.nixbox-warmed\"" 2>/dev/null; then | ||
| log_sub "$name: already warmed" | ||
| return 0 | ||
| fi | ||
|
|
||
| log "==> Warming $name cache from host (one-time per workspace)..." | ||
| nixbox run "mkdir -p \"\$HOME/$guest_relpath\"" | ||
| tar -C "$host_src" -cf - . \ | ||
| | nixbox run "tar -C \"\$HOME/$guest_relpath\" -xf - && touch \"\$HOME/$guest_relpath/.nixbox-warmed\"" | ||
| log_sub "$name: done" | ||
| } | ||
|
|
||
| warm "$HOME/.cache/coursier" ".cache/coursier" coursier | ||
| warm "$HOME/.ivy2" ".ivy2" ivy2 | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.