Open nitely opened 6 months ago
It is not the Nim compiler that is slow to generate C code. The C compiler seems to have a hard time compiling the huge array generated in the c code. The other problem is that Nim generate massive types for the elements of seqs.
It generates 300k lines C code
@ringabout But it still indicates that the Nim compiler produces unreasonable C code.
Quit using const
specifier for array/seq seems to make it faster
Description
C/C++ backend takes +30 min to compile the below example in release mode. For JS backend it takes 0.5s to compile. It only takes so long in release mode. Debug mode takes 15s. Original issue reported in the nim-regex package.
Nim Version
Nim Compiler Version 2.1.1 [Linux: amd64] Compiled at 2024-04-06 Copyright (c) 2006-2024 by Andreas Rumpf
git hash: 8c9fde76b547f19e3663d71d4ea644cee700d130 active boot switches: -d:release
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
Replacing seq[int] by seq[int8] is also slow. Replacing seq[int8] by string, which should be a fairly similar data structure compiles fast-ish.