question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compilation is very slow on some files due to implicit search repeatedly diverging

See original GitHub issue

Compiler version

3.1.0 / 3.1.1

Minimized code

// using "org.typelevel" %% "cats-effect-kernel" % "3.3.4"
import cats.effect.kernel.Resource

import cats.syntax.apply.catsSyntaxApply
import cats.Monad

object middlewares {

  def withToken[F[_]: Monad](getToken: F[Unit]): Resource[F, Unit] =
    Resource.eval(getToken) *> Resource.eval(getToken)

}

Expectation

Sub-second recompilation when there are no changes in the file except whitespace.

Reality

It takes 7-8 seconds to compile this file on a fresh JVM. Recompilation also takes nearly as much, and the presentation compiler is affected as well (which is visible when you e.g. attempt to get completions in Metals).

Notes

I think the *> call is the culprit here. Removing it fixes the issue.

Scala 2.13.8 compiles this in 2 seconds with sub-second incremental recompilations.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
smartercommented, Jan 25, 2022

@dwijnand removed the itype:bug label

IMO this is a severe enough regression that this qualifies as a bug. Luckily I think I have a fix: https://github.com/lampepfl/dotty/pull/14353

2reactions
kubukozcommented, Jan 26, 2022

Your fix works 😃 tried with a publishLocal and this compiles much faster now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swift Slow Compile Times Fix | Apple Developer Forums
Under that, there is an option "Find Implicit Dependencies", uncheck that ... Swift compiles only a handful of files and compile times improve...
Read more >
Speeding Up Compilation Time with scalac-profiling
It's worth investigating why slow compiles happens as as it is often possible to fix our projects to compile faster!
Read more >
Why is my Rust build so slow? - Hacker News
I would say that due to headers, massive portability baggage and a lack of a standard build system, compiling C++ is even worse....
Read more >
Why is compilation very slow for Scala programs?
Some people see compile speeds that are lower than that. That's usually because they use constructs (often imported from a library) that are ......
Read more >
TSConfig Reference - Docs on every TSConfig option
A file specified by exclude can still become part of your codebase due to an ... In some cases where no type annotations...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found