Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Optimize Mill evaluation logic #3388

Merged
merged 9 commits into from
Aug 19, 2024
Merged

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Aug 19, 2024

Pre-compute a bunch of values we use to compute the code signature of enclosing objects of task methods.

Cuts down the time taken of a hot no-op ./mill __.compile (i.e. pure overhead) on the Mill repo from ~4000ms to ~2000ms

Benchmarked were run ad hoc on my laptop by making the -w flag loop immediately rather than waiting

diff --git a/runner/src/mill/runner/Watching.scala b/runner/src/mill/runner/Watching.scala
index 08e8df5e3f..e8f41a3cc5 100644
--- a/runner/src/mill/runner/Watching.scala
+++ b/runner/src/mill/runner/Watching.scala
@@ -23,6 +23,7 @@ object Watching {
       evaluate: Option[T] => Result[T]
   ): (Boolean, T) = {
     var prevState: Option[T] = None
+    var previous = System.currentTimeMillis()
     while (true) {
       val Result(watchables, errorOpt, result) = evaluate(prevState)
       prevState = Some(result)
@@ -40,10 +41,13 @@ object Watching {
         return (errorOpt.isEmpty, result)
       }

-      val alreadyStale = watchables.exists(!_.validate())
+      val alreadyStale = true
       if (!alreadyStale) {
         Watching.watchAndWait(logger, setIdle, streams.in, watchables)
       }
+      val next = System.currentTimeMillis()
+      println("Delta Millis " + (next - previous))
+      previous = next
     }
     ???
   }

Covered by the existing integration/invalidation/codesig-* tests

@lihaoyi lihaoyi marked this pull request as ready for review August 19, 2024 08:48
@lihaoyi lihaoyi merged commit e863bee into com-lihaoyi:main Aug 19, 2024
31 checks passed
@lefou lefou added this to the 0.12.0 milestone Aug 19, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants