I run bots with GNU parallel. The worker in Nim does its thing and exits, usually lasting no more than a few minutes, it might be 100s of thousands of times over many days to completion. This system has advantages, such as no issue with memory leaks caused by my convoluted code; the ability to hot-code since it is included in the next worker startup; interesting GNU parallel options. Anyway, I usually try to compile with -d:release but it takes longer and I often forget. Recently running on a (intentionally) fanless computer for the first time, and noticed 100C on the CPU got a little worried, right? So after recompiling with -d:release the heat and electric were cut by half. That's a Big Deal.. It's easy to overlook how significant -d:release is when on a properly cooled computer that can power through.
The docs say -d:release "Turns on the optimizer. More aggressive optimizations are possible". I'd like to try aggressive. Is there a list of ways?
I usually try to compile with -d:release but it takes longer and I often forget.
You can use config.nims to stop relying on your memory for this. Here I add LTO flags for release/danger builds. You can also just set it to build in release mode by default.
--gc:arc
if defined(release) or defined(danger):
--opt:speed
--passC:"-flto"
--passL:"-flto"
Here's an example of using a small bash script for building with gcc PGO: https://forum.nim-lang.org/t/7926#51699