Skip to content

Commit 73d2cee

Browse files
committed
.
1 parent 35336bb commit 73d2cee

15 files changed

Lines changed: 26 additions & 141 deletions

File tree

core/exec/src/mill/exec/Execution.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ case class Execution(
4545
) extends GroupExecution with AutoCloseable {
4646

4747
// Track nesting depth of executeTasks calls to only show final status on outermost call
48-
val executionNestingDepth = new AtomicInteger(0)
48+
private val executionNestingDepth = new AtomicInteger(0)
4949

5050
// Lazily computed worker dependency graph, cached for the duration of the execution. It's
5151
// ok to take a snapshot of the cache, since the workerCache entries we may want to remove
@@ -187,7 +187,6 @@ case class Execution(
187187
ExecutionLogs.logDependencyTree(
188188
interGroupDeps,
189189
indexToTerminal,
190-
outPath,
191190
runArtifacts
192191
)
193192
// Prepare a lookup tables up front of all the method names that each class owns,
@@ -410,7 +409,6 @@ case class Execution(
410409

411410
ExecutionLogs.logInvalidationTree(
412411
interGroupDeps = interGroupDeps,
413-
outPath = outPath,
414412
runArtifacts = runArtifacts,
415413
uncached = uncached,
416414
changedValueHash = changedValueHash,

core/exec/src/mill/exec/ExecutionLogs.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import mill.api.Task
55
import mill.internal.{InvalidationForest, SpanningForest}
66

77
import java.util.concurrent.ConcurrentHashMap
8-
import scala.annotation.unused
98
import scala.jdk.CollectionConverters.EnumerationHasAsScala
109

1110
private object ExecutionLogs {
1211
def logDependencyTree(
1312
interGroupDeps: Map[Task[?], Seq[Task[?]]],
1413
indexToTerminal: Array[Task[?]],
15-
@unused outPath: os.Path,
1614
runArtifacts: LauncherOutFiles
1715
): Unit = {
1816
val dependencyTreePath = os.Path(runArtifacts.dependencyTree)
@@ -28,7 +26,6 @@ private object ExecutionLogs {
2826
}
2927
def logInvalidationTree(
3028
interGroupDeps: Map[Task[?], Seq[Task[?]]],
31-
@unused outPath: os.Path,
3229
runArtifacts: LauncherOutFiles,
3330
uncached: ConcurrentHashMap[Task[?], Unit],
3431
changedValueHash: ConcurrentHashMap[Task[?], Unit],

core/exec/src/mill/exec/GroupExecution.scala

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ trait GroupExecution {
5757
def env: Map[String, String]
5858
def failFast: Boolean
5959
def ec: Option[ThreadPoolExecutor]
60-
def isFinalDepth: Boolean
6160
def codeSignatures: Map[String, Int]
6261
def systemExit: ( /* reason */ String, /* exitCode */ Int) => Nothing
6362
def exclusiveSystemStreams: SystemStreams
@@ -287,12 +286,6 @@ trait GroupExecution {
287286
kind
288287
)
289288

290-
def withTaskWriteLock[T](t: LauncherLocking.Lease => T): T = {
291-
val lease = acquireTaskLock(LauncherLocking.LockKind.Write)
292-
try t(lease)
293-
finally lease.close()
294-
}
295-
296289
// Helper to evaluate the task with full caching support
297290
def evaluateTaskWithCaching(): GroupExecution.Results = {
298291
case class CacheProbe(
@@ -438,7 +431,8 @@ trait GroupExecution {
438431
// Helper to evaluate build override only (no task evaluation)
439432
def evaluateBuildOverrideOnly(located: Located[Appendable[BufferedValue]])
440433
: GroupExecution.Results = {
441-
withTaskWriteLock { _ =>
434+
val lease = acquireTaskLock(LauncherLocking.LockKind.Write)
435+
try {
442436
val (execRes, serializedPaths) =
443437
if (os.Path(labelled.ctx.fileName).endsWith("mill-build/build.mill")) {
444438
val msg =
@@ -465,7 +459,7 @@ trait GroupExecution {
465459
}
466460
}
467461
cachedResult(execRes, serializedPaths)
468-
}
462+
} finally lease.close()
469463
}
470464

471465
// Three-way conditional:

core/internal/src/mill/internal/LauncherRecordStore.scala

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,7 @@ private[mill] object LauncherRecordStore {
2828
))
2929
catch { case _: Throwable => () }
3030

31-
def sweepActive(out: os.Path): Seq[Record] = {
32-
val dir = out / os.RelPath(DaemonFiles.millLauncherFiles)
33-
if (!os.exists(dir)) Nil
34-
else
35-
os.list(dir)
36-
.filter(os.isFile(_))
37-
.flatMap(readActiveRecord(_, removeStale = true))
38-
.sortBy(record => runIdSortKey(record.runId))
39-
}
31+
def sweepActive(out: os.Path): Seq[Record] = scanActive(out, removeStale = true)
4032

4133
def mostRecentActive(out: os.Path): Option[Record] =
4234
scanActive(out, removeStale = false).lastOption

core/internal/src/mill/internal/OutputDirectoryLayout.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private[mill] object OutputDirectoryLayout {
2222
}.flatten
2323
}
2424

25-
def effectiveEnvForOutMode(
25+
private def effectiveEnvForOutMode(
2626
outMode: OutFolderMode,
2727
workDir: os.Path,
2828
env: Map[String, String]

integration/bsp-util/src/BspServerTestUtil.scala

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -284,22 +284,9 @@ object BspServerTestUtil {
284284
}
285285

286286
private def waitForProcessExit(proc: os.SubProcess, timeoutMillis: Long): Unit = {
287-
val waitIntervalMillis = 50L
288-
val deadlineNanos = System.nanoTime() + timeoutMillis * 1000000L
289-
290-
while (proc.isAlive() && System.nanoTime() < deadlineNanos) {
291-
Thread.sleep(waitIntervalMillis)
292-
}
293-
294-
if (proc.isAlive()) {
287+
if (!proc.waitFor(timeoutMillis)) {
295288
proc.destroy(recursive = false)
296-
297-
val shutdownDeadlineNanos = System.nanoTime() + 5000L * 1000000L
298-
while (proc.isAlive() && System.nanoTime() < shutdownDeadlineNanos) {
299-
Thread.sleep(waitIntervalMillis)
300-
}
301-
302-
if (proc.isAlive()) {
289+
if (!proc.waitFor(5000L)) {
303290
throw new RuntimeException("BSP server did not exit within the expected timeout")
304291
}
305292
}

integration/dedicated/bsp-server-error/src/BspServerErrorTests.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ object BspServerErrorTests extends UtestIntegrationTestSuite {
4545
bspLog = Some((bytes, len) => stderr.write(bytes, 0, len))
4646
) { (buildServer, initRes) =>
4747

48-
val firstServerDeadline = System.nanoTime() + 5000L * 1000000L
49-
while (firstServerProc.isAlive() && System.nanoTime() < firstServerDeadline) {
50-
Thread.sleep(50L)
51-
}
48+
firstServerProc.waitFor(5000L)
5249
assert(!firstServerProc.isAlive())
5350

5451
val firstServerStderrStr = new String(firstServerStderr.toByteArray)

integration/dedicated/bsp-server-reload/src/BspServerReloadTests.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ object BspServerReloadTests extends UtestIntegrationTestSuite {
9393
def eventData(event: b.BuildTargetEvent): (String, b.BuildTargetEventKind) =
9494
(event.getTarget.getUri.split("/").last, event.getKind)
9595

96-
// `lib` is not in this set: its bspBuildTarget snapshot (displayName,
97-
// baseDirectory, tags, languageIds, capabilities, plus its
98-
// dependencyUris) is unchanged across the build.mill edit, so the
99-
// ChangeNotifier correctly does not fire a CHANGED event for it.
96+
// `lib`'s target snapshot is unchanged across the build.mill edit.
10097
val expectedChanges = Set(
10198
"thing" -> b.BuildTargetEventKind.DELETED,
10299
"app" -> b.BuildTargetEventKind.DELETED,

runner/bsp/worker/src/mill/bsp/worker/BspEvaluators.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import mill.api.daemon.internal.{
1111
TaskApi
1212
}
1313
import mill.api.daemon.internal.bsp.BspJavaModuleApi
14-
import mill.api.daemon.Watchable
1514

1615
/**
1716
* Manages BSP module discovery and lookup for a Mill build.
@@ -20,8 +19,7 @@ import mill.api.daemon.Watchable
2019
class BspEvaluators(
2120
workspaceDir: os.Path,
2221
val evaluators: Seq[EvaluatorApi],
23-
debug: (() => String) => Unit,
24-
val watched: Seq[Watchable]
22+
debug: (() => String) => Unit
2523
) {
2624
import BspEvaluators.*
2725

runner/bsp/worker/src/mill/bsp/worker/BspSessionCoordinator.scala

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ private[worker] class BspSessionCoordinator(
4747
case NonFatal(_) => None
4848
}
4949

50-
def waitForFileLock(): Locked = {
51-
while (true) {
52-
val tryLocked = fileLock.tryLock()
53-
if (tryLocked.isLocked) return tryLocked
54-
Thread.sleep(10L)
55-
}
56-
throw new IllegalStateException("unreachable")
57-
}
58-
5950
def terminateOther(pidOpt: Option[Long]): Unit =
6051
pidOpt match {
6152
case Some(pid) if pid == sessionProcessPid =>
@@ -128,7 +119,7 @@ private[worker] class BspSessionCoordinator(
128119
s"Another Mill BSP server is running with PID ${pidOpt.fold("<unknown>")(_.toString)} waiting for it to be done..."
129120
)
130121

131-
waitForFileLock()
122+
fileLock.lock()
132123
}
133124

134125
val daemonPid = ProcessHandle.current().pid()

0 commit comments

Comments
 (0)