andrey-zherikov / argparse

Parser for command-line arguments
https://andrey-zherikov.github.io/argparse/
Boost Software License 1.0
30 stars 6 forks source link

`-unittest` requires an enormous amount of memory to compile #122

Closed SirNickolas closed 9 months ago

SirNickolas commented 9 months ago

Having a mere import argparse; in a program and compiling it with -unittest compiles and runs all of the argparse’s tests. Or at least attempts to. If I run dmd -lowmem -unittest -i test.d on a file containing this single line, the compiler devours 2.8 GB of RAM; then I kill it, or else my system freezes. I have no idea how hungry it is in reality.

In my opinion, inspecting some UDAs shouldn’t involve so much work. I’ll have a look at the code and see if I can figure out what is going on there.

SirNickolas commented 9 months ago

As I suspected, almost all metaprogramming is done with template instantiation, although many things can be moved to CTFE. The compiler is required to cache all (successful) template instantiations for every unique combination of arguments—thatʼs why -lowmem didnʼt help.

Working on this; will send a PR as soon as I am able to run tests.