savi
savi copied to clipboard
Improve compilation speed
For an almost empty project, it takes about 32 seconds to compile.
> savi build --print-perf spec
9 ms : manifests
764 ms : load
1 ms : populate_types
14 ms : namespace
336 ms : reparse
15 ms : populate
44 ms : macros
35 ms : sugar
1433 ms : refer_type
21 ms : lambda
158 ms : flow
205 ms : classify
116 ms : type_context
236 ms : refer
195 ms : jumps
101 ms : inventory
327 ms : pre_subtyping
1989 ms : local
515 ms : pre_infer
84 ms : completeness
2576 ms : infer_edge
3387 ms : infer
1637 ms : reach
134 ms : verify
1158 ms : privacy
110 ms : paint
1812 ms : type_check
6306 ms : codegen
4719 ms : binary
The biggest culprit is currently LLVM - I think we need to set up a two-stage build in the https://github.com/savi-lang/llvm-static repo to better optimize the LLVM build.
Most likely I am using a debug build! Let me try again with gmake ci config=release!
Or to have a savi check command, that just does type checking without code generation. Most of the time that'd help.
I'm planning to add a watch modes where the compiler can make use of its in-memory caching to speed up recompilation of the same program, whenever files change. I suspect this will help with the speed of the basic development workflow.
I'm definitely not opposed to having a mode that only runs compilation checks, though I personally wouldn't use it very often, because in my development workflow, whenever I get the program to compile i always want to run the tests next.
Let me try again with
gmake ci config=release
That won't build the release-mode compiler - you want to run gmake build/savi-release.
Just for reference, with savi-release it's 3x faster (10 seconds total instead of 32):
> time savi build --print-perf spec
1 ms : manifests
181 ms : load
0 ms : populate_types
1 ms : namespace
20 ms : reparse
2 ms : populate
14 ms : macros
7 ms : sugar
79 ms : refer_type
6 ms : lambda
35 ms : flow
35 ms : classify
26 ms : type_context
45 ms : refer
22 ms : jumps
12 ms : inventory
25 ms : pre_subtyping
337 ms : local
92 ms : pre_infer
7 ms : completeness
451 ms : infer_edge
619 ms : infer
201 ms : reach
13 ms : verify
148 ms : privacy
11 ms : paint
361 ms : type_check
806 ms : codegen
4922 ms : binary
11.711u 0.346s 0:09.81 122.8% 93895+1492k 0+20io 38pf+0w
And 50% of that time is spent in LLVM.