Cabal: slow `Resolving dependencies`

Trying to optimize my workflow on building simple app with cabal, I realized that
Resolving dependencies...
takes quite a long time.
Everything else seems to take much less time to build.

Why is this happening, and how do I solve or mitigate the delay?

I’ve experienced a 1-2 minutes delay due to the solver in some cardano projects.

Have you tried with a freeze file?

Yep, I already have cabal freeze file. Still, it takes over 10 seconds for a miniscule project.

A lot of performance improvements were made in 3.6, which may help.

Thank you for suggestion! I am already using cabal 3.6, though.

resolving dependencies (via cabal configure) for the cabal project itself, which is not tiny, is only 2s on my machine. So I don’t know what to tell you about this ten second delay. You can run cabal configure -v3 to get a detailed log of what cabal is doing, which might indicate where it is spending most of its time.

Wow, thank you for the directions! Never thought about debugging it. I’d see what is taking so much time.

I realized the dependency part itself did not take that much time. Let me see what is causing problem.
EDIT: It seems a typical compile-time and link-time perf problem.