-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nim: improve build time by 1.5x #11
Conversation
I can confirm the speedup. |
Thanks |
@nordlow i don't understand the numbers in the benchmark:
i can't run the benchmark locally because of https://github.com/nordlow/compiler-benchmark/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc (i'm on osx), but by doing it manally i get a 2X slowdown in terms of compilation times, not 613X, compared to C:
what am i missing? |
yeah on my PC C++
C
Nim
|
BTW Nim can use |
The Tiny C Compiler is being used as reference for C in the benchmark. Its incredibly fast. |
Nim now uses tcc as build backend when its found in the exe path. |
Cool! |
/cc @xflywind
note
the good news is that it's mostly the backend cgen that takes time:
clang -o /tmp/z01 generated/c/main.c
2s
XDG_CONFIG_HOME= nim c --compileonly -o:/tmp/z04x --nimcache:/tmp/c07f --checks:off --stacktrace:off --opt:none --hints:off generated/nim/main.nim
1.18s
XDG_CONFIG_HOME= nim c -o:/tmp/z05 --nimcache:/tmp/c07f --checks:off --stacktrace:off --opt:none --hints:off generated/nim/main.nim
4.1s
note 1
with
--hint:cc --listcmd
it shows:clang -c -w -ferror-limit=3 -I/Users/timothee/git_clone/nim/Nim_devel/lib -I/Users/timothee/git_clone/nim/temp/compiler-benchmark/generated/nim -o /tmp/c08d/@mmain.nim.c.o /tmp/c08d/@mmain.nim.c
2.8s
note 2
#8 (comment)
the benchmark should allow reporting not just debug builds; for eg nim enables lots of checks by default which are optimized for development speed/improved debugging, but can slow down compilation times; languages shouldn't be penalized for having more debugging checks on by default :)
note 3
--gc:arc
is about 1.2x slower; the cgen contains this:which has more instructions compared to gc:refc:
note 4
codegen generates:
if it generated the following simplified code isntead:
it would bring down clang compilation time by ~1.15x, not sure whether it's worth it since in practice other factors dominate (eg nim VM, IC etc)