Skip to content

Conversation

@demotomohiro
Copy link
Contributor

No description provided.

@demotomohiro demotomohiro marked this pull request as draft November 10, 2025 11:05
@demotomohiro demotomohiro force-pushed the cache-config branch 4 times, most recently from cd80eee to 29b2c99 Compare November 16, 2025 04:48
@demotomohiro demotomohiro marked this pull request as ready for review November 17, 2025 14:27
@Araq
Copy link
Member

Araq commented Nov 27, 2025

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

@arnetheduck
Copy link
Contributor

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 ..

@demotomohiro
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants