Skip to content
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

Busy spin in SbtTask results in high CPU usage #671

Closed
Tracked by #1
dimitarg opened this issue Jun 21, 2023 · 1 comment · Fixed by typelevel/weaver-test#44
Closed
Tracked by #1

Busy spin in SbtTask results in high CPU usage #671

dimitarg opened this issue Jun 21, 2023 · 1 comment · Fixed by typelevel/weaver-test#44

Comments

@dimitarg
Copy link

dimitarg commented Jun 21, 2023

Consider

package repro
import cats.effect.IO
import scala.concurrent.duration._
import weaver.SimpleMutableIOSuite

object Repro extends SimpleMutableIOSuite {
  test("asd") {
    IO.sleep(120.seconds).as(success)
  }
}

This will result in 100% CPU usage (i.e. 1 core) for the duration of the run.
The reason appears to be while (!finished && !isDone.get()) { in SbtTask.execute, which is in effect a busy spin (until isDone is done).

Of course, feel free to close at your discretion if this is deemed not an issue.

@Baccata
Copy link
Contributor

Baccata commented Jun 21, 2023

To be honest it's kinda expected. However it could be good to experiment with blocking queues instead of concurrent linked queues.

Unfortunately I'm lacking the capacity to explore this in the short term.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants