Nim icon indicating copy to clipboard operation
Nim copied to clipboard

implements #25268; cache configuration evaluation

Open demotomohiro opened this issue 1 month ago • 3 comments

demotomohiro avatar Nov 10 '25 11:11 demotomohiro

Can this be enabled by default? What are the effects on compile-time and memory consumption when the cache hits?

Araq avatar Nov 27 '25 07:11 Araq

Can this be enabled by default?

not without a side effect tracking mechanism - in .nims, you can fetch dynamic stuff like the latest git commit hash, read files that change, compile c libraries and so on - it's quite unsafe to cache the outcome of any such operation ..

arnetheduck avatar Nov 27 '25 07:11 arnetheduck

I tested on my Raspberry Pi 5 with Raspberry Pi OS (64-bit) with simple nim code uses only default config files. When the cache is used, compile time is changed from 0.430 to 0.322 sec and memory consumption from 31.094MiB to 24.816MiB.

rasp@rasp5:~/proj/Nim $ mkdir mytests
rasp@rasp5:~/proj/Nim $ echo 'echo "test"' > mytests/test.nim
rasp@rasp5:~/proj/Nim $ time nim c --cachecfg:off --skipUserCfg:on --skipParentCfg:on -f mytests/test.nim 
0.000 evaluating config files
Hint: used config file '/home/rasp/proj/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/rasp/proj/Nim/config/config.nims' [Conf]
0.148 done evaluating config files
......................................................................
CC: system/exceptions.nim
CC: std/private/digitsutils.nim
CC: system/dollars.nim
CC: system.nim
CC: test.nim
Hint:  [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
29061 lines; 0.604s; 31.113MiB peakmem; proj: /home/rasp/proj/Nim/mytests/test.nim; out: /home/rasp/proj/Nim/mytests/test [SuccessX]

real    0m0.755s
user    0m0.854s
sys     0m0.041s
rasp@rasp5:~/proj/Nim $ time nim c --cachecfg:on --skipUserCfg:on --skipParentCfg:on mytests/test.nim 
0.000 evaluating config files
Hint: used config file '/home/rasp/proj/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/rasp/proj/Nim/config/config.nims' [Conf]
0.148 done evaluating config files
......................................................................
Hint:  [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
29061 lines; 0.279s; 31.094MiB peakmem; proj: /home/rasp/proj/Nim/mytests/test.nim; out: /home/rasp/proj/Nim/mytests/test [SuccessX]

real    0m0.430s
user    0m0.399s
sys     0m0.030s
rasp@rasp5:~/proj/Nim $ time nim c --cachecfg:on --skipUserCfg:on --skipParentCfg:on mytests/test.nim 
0.001 loading cached config
0.001 done loading cached config
......................................................................
Hint:  [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
18317 lines; 0.319s; 24.816MiB peakmem; proj: /home/rasp/proj/Nim/mytests/test.nim; out: /home/rasp/proj/Nim/mytests/test [SuccessX]

real    0m0.322s
user    0m0.287s
sys     0m0.035s

demotomohiro avatar Nov 28 '25 09:11 demotomohiro