nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

[regression] Nimscript makes a program slower and more bloated #9995

Closed narimiran closed 5 years ago

narimiran commented 5 years ago

When using filename.nims on the latest devel (v0.19.9) it somehow creates a slower and more bloated (more RAM used) program than when you pass the flags directly when compiling. This does not happen on 0.19 stable.

Example

The original command, without .nims file:

nim c -d:release --gc:regions nim/day09

produces a file which runs in ~0.25 seconds, taking ~140 MB of RAM.

Putting --gc:regions in a day09.nims file and compiling it produces a file which runs in ~0.50 seconds, taking ~240 MB of RAM.

This is not limited to --gc:regions, a similar thing happens when using --gc:refc flag with the same file:

Expected Output

To have the same/similar results when using the flags on the command line and in .nims file.

Additional Information

$ nim -v
Nim Compiler Version 0.19.9 [Linux: amd64]
Compiled at 2018-12-15
Copyright (c) 2006-2018 by Andreas Rumpf

active boot switches: -d:release
timotheecour commented 5 years ago

the regression was pretty serious, leading to using 100% CPU and eating up all the RAM, ending up crashing my macbook pro 16GB RAM

see my PR to fix it: https://github.com/nim-lang/Nim/pull/10007