Commit Graph

7 Commits

Author SHA1 Message Date
Brian Hotopp 3f6fd595ff [2.x] feat: Resolve dependencies in parallel under the super shell
Building on #9270 (which parallelized resolution in non-interactive runs by
narrowing the lm-coursier lock to only fire while coursier renders its
interactive progress bar), this makes `update` resolve in parallel under the
interactive super shell as well.

Under the super shell, LMCoursier.coursierLoggerTask previously returned None,
so coursier drew its own per-module progress bars and resolution stayed
serialized (those bars are not safe to render concurrently). It now supplies a
CacheLogger, which both suppresses coursier's bars and flips #9270's
progressBarActive predicate to false, so resolution runs in parallel. Progress
is rendered at the sbt task level instead.

Resolution progress is tracked by a per-command ResolutionProgress instance,
created in MainLoop.next alongside Keys.taskProgress and held under an
AttributeKey with the same lifecycle -- no JVM-global state. coursierLoggerTask
reads it from State and hands it to the ResolutionProgressLogger that coursier's
download threads call; TaskProgress holds the same instance and appends a single
aggregate line at render time, e.g. "Updating 18 modules, 240 artifacts,
31.0 MiB". The instance is born empty per command and discarded with it, so
totals never leak across commands and the count never resets mid-update (a
single update runs a resolve phase and a separate artifacts phase).

v1 renders one aggregate line because it needs no schema change; per-module
status lines (which would add a status field to ProgressItem) are a follow-up.
UpdateRun's report-building lock is left as a separate follow-up since the
network-heavy paths (ResolutionRun/ArtifactsRun) are already unlocked.

re: #5627

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 15:46:53 -04:00
BrianHotopp d4f54fd5b6
[2.x] fix: Report a missing input file clearly instead of an opaque SerializationException (#9271)
When a file referenced by a task's inputs/outputs (e.g. Compile / resources +=
file("nope.txt")) does not exist, hashing the task's cache key threw a
NoSuchFileException deep inside sjsonnew serialization. It surfaced as an opaque
sjsonnew.SerializationException that dumped the entire input list, with the real
cause buried several `Caused by:` levels down, so users routinely mistook it for
a corrupt cache and reached for `clean`.

ActionCache.mkInput now catches the hashing failure, detects a NoSuchFileException
anywhere in the cause chain (ActionCache.findMissingFile), and throws a
MessageOnlyException naming the file:

    [error] file referenced by the build does not exist: nope.txt

util-cache gains a dependency on util-control (a leaf module, no cycle) for
MessageOnlyException.

Fixes #9217.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-30 19:29:41 -04:00
BrianHotopp 0ee7323110
[2.x] fix: Parallelize dependency resolution when no progress bar is rendered (#9270)
update held a process-global lock around coursier resolution and artifact
fetching whenever a logger was set OR coursier was not in fallback mode. That
lock exists only to serialize coursier's interactive progress bar, which is
rendered solely when no custom logger is supplied and coursier is not in
fallback mode. The loggerOpt.nonEmpty clause therefore over-serialized the
common non-interactive case (IntelliJ re-imports, CI, any non-TTY run, where
sbt supplies a quiet debug-only logger), making update scale with the number
of modules rather than the number of distinct artifacts.

Fixes #5508.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-28 15:31:38 -04:00
BrianHotopp 3eeac9deae
[2.x] fix: Collapse duplicate subtrees in dependency tree rendering (#9226)
Fixes #6886.

dependencyTree, dependencyBrowseTree, and inspect tree re-explore
the same node once per incoming edge. In a DAG with N levels and M
children per node the rendered output is O(M^N) -- the OP needed
>16 GB heap, #7360 has a 6 GB heap dump, and Friendseeker's analysis
on the issue showed the exponential re-traversal directly.

Fix: track a visited set across the renderer's recursion. The first
time a node is encountered it is rendered in full; on subsequent
visits the entry collapses to a one-line +- <id> (*) (ASCII) or a
<id> (*) leaf (JSON), matching Maven's dependency:tree (*)
convention. Cycle detection (separate parents set, (cycle) marker)
is unchanged.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 19:15:47 -04:00
Dream 544f56695a
[2.x] feat: Add cacheVersion setting for global cache invalidation (#8993)
* [2.x] feat: Add cacheVersion setting for global cache invalidation

**Problem**
There was no escape hatch to invalidate all task caches when needed.

**Solution**
Add `Global / cacheVersion` setting that incorporates into the cache key
hash. Changing it invalidates all caches. Defaults to reading system
property `sbt.cacheversion`, or else 0L. When 0L, the hash is identical
to the previous behavior (backward compatible).

Fixes #8992

* [2.x] refactor: Simplify BuildWideCacheConfiguration and add cacheVersion test

- Replace auxiliary constructors with default parameter values
- Add unit test verifying cacheVersion invalidates the cache

* [2.x] fix: Restore auxiliary constructors for binary compatibility

* [2.x] test: Improve cacheVersion scripted test and add release note

- Scripted test now verifies cache invalidation via a counter
  that increments only when the task body actually executes
- Add release note documenting the cacheVersion setting
2026-04-01 11:23:10 +09:00
seroperson 6dcce4cf2d
[2.x] fix: addressing review comments 2026-03-13 09:34:32 +03:00
eugene yokota ecca26175e
[sbt 2.x] remote cache (#7464)
For the details about this PR, please see the blog post https://eed3si9n.com/sbt-remote-cache/.

* Add cache basics
* Refactor Attributed to use StringAttributeMap, which is Map[StringAttributeKey, String]
* Implement disk cache
* Rename Package to Pkg
* Virtualize packageBin
* Use HashedVirtualFileRef for packageBin
* Virtualize compile task
2024-02-07 10:34:06 -05:00