Surprisingly, I'm having some issues with Nim compilation speed.
Given that I use to make frequent changes to the project I'm working on (https://github.com/arturo-lang/arturo), that also means frequent re-builds.
However, this seems too slow:
Hint: 213449 lines; 144.014s; 624.43MiB peakmem; Dangerous Release build
The above is on a 13-inch, 2018 MacBook Pro.
These are my build options:
c --opt:speed --colors:off -d:release -d:danger --panics:off --gc:orc --checks:off --overflowChecks:on -d:ssl --threads:on
And here is my Nim version:
Nim Compiler Version 1.4.2 [MacOSX: amd64]
Compiled at 2020-12-29
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release
Any ideas/suggestions?
Thanks a lot for the input.
It's true that I've rather overdone it with the templates.
Is there any easy way to track/report where most template expansions take place? (I've obviously lost track of them all...)
P.s. Regarding performance, I know what you mean. I guess I'll have to start benchmarking again - although I wanted to reach a stable version first... Still the performance doesn't look too bad.
I made dumpincludes a utility that can at least tell you which modules are getting huge expansions:
https://forum.nim-lang.org/t/7309
This can be useful to let you know how bad the problem really is.
It's true that not everything works all the time. (I almost warned about that. The C++ backend also fails me from time to time.)
It is still worth trying tcc on a program-by-program basis. It's my default compiler, and I rarely have any trouble. If you can track down the errors inducing your segfaults then you can maybe help Nim keep a faster backend working.
Not repeating work is often the biggest "easy" optimization. I almost mentioned IC as a near-term hope for @drkameleon, but it seems not yet ready to give speed-up numbers.
Anyway, I think we all probably long for IC. :-) That said, your comment raises a question - would a large, single file .nim compile be sped up by IC or not? I just haven't followed the design well enough to know.
Anyway, I think we all probably long for IC. :-) That said, your comment raises a question - would a large, single file .nim compile be sped up by IC or not (EDIT: well, I guess its import web may not change and that alone is a huge boost)? I just haven't followed the design well enough to know the granularity.
The granularity is the Nim module. A large, single file .nim compile itself won't see speedups. However, one of the biggest module I've seen is system.nim itself. It's rare that you change the stdlib when you recompile, so in practice every project will see speedups.