Parallelization of the C backend. V -prod is now 12 times faster on a 14 core cpu! #23206
Pinned
medvednikov
started this conversation in
Blog
Replies: 1 comment
-
Great job |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
V is very fast, but it used to be true only for debug builds.
For example, self compilation without optimization takes 0.4s, while an optimized build took a whopping 24 seconds!
This is no longer the case!
The C backend is now parallel, V's optimized compilation speed is now 12 times faster on a 14 core cpu: 2.1s vs 24s. (M4 MacBook Pro)
Basically if you have an N core cpu,
v -prod
will be ≈N times faster!(for now it needs a
-parallel-cc
flag, only non-Windows platforms, Windows will be supported as well)Note, that the C optimizers work best when they have all the info about the program. That's why many C/C++ devs merge all project files into a single file before doing a production build. (Don't do this in V, it does it for you!🙂) So to achieve the absolutely best performance before doing a production build, run
v -prod
on a single thread and a single file (without-parallel-cc
).v -prod -parallel-cc ...
is a good compromise for achieving significantly better performance compared to the unoptimizedv ...
, while incurring only a minor increase in compilation time.-parallel-cc
gives a nice speed-up even without optimization, when using Clang/GCC, and on weaker hardware.2x speed-up on MacBook air M3
Since lots of software can't be built with tcc (e.g. when using Cocoa + Objective C), this is really useful.
update
More results for different CPUs:
Ryzen 7600X (7x speed-up)
Intel Core i5-1240P (8x speed-up)
Beta Was this translation helpful? Give feedback.
All reactions