-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit provides the ability to rebuild system images much faster. The key observation is that most of the time in sysimage build is spent in LLVM generating native code (serializing julia's data structures is quite fast). Thus if we can re-use the code already generated for the system image we're currently running, we'll save a fair amount of time. Unfortunately, this is not 100% straightforward since we were assuming that no linking happens in a number of places. This PR hacks around that, but it is not a particularly satisfying long term solution. That said, it should work fine, and I think it's worth doing, so that we can explore the workflow adjustments that would rely on this. With that said, here's how to use this (at the low level, of course PkgCompiler would just handle this) ```shell $ mkdir chained $ time ./usr/bin/julia --sysimage-native-code=chained --sysimage=usr/lib/julia/sys.so --output-o chained/chained.o.a -e 'Base.__init_build();' real 0m9.633s user 0m8.613s sys 0m1.020s $ cp ../usr/lib/julia/sys-o.a . # Get the -o.a from the old sysimage $ ar x sys-o.a # Extract it into text.o and data.o $ rm data.o # rm the serialized sysimg data $ mv text.o text-old.o $ llvm-objcopy --remove-section .data.jl.unique text-old.o # rm the link between the native code and the old sysimg data $ ar x chained.o.a # Extract new sysimage files $ gcc -shared -o chained.so text.o data.o text-old.o # Link everything $ ../julia --sysimage=chained.so ``` As can be seen, regenerating the system image took about 9s (the subsequent commands aren't timed here, but take less than a second total). This compares very favorably with a non-chained sysimg rebuild: ``` time ./usr/bin/julia --sysimage=usr/lib/julia/sys.so --output-o nonchained.o.a -e 'Base.__init_build();' real 2m42.667s user 2m39.211s sys 0m3.452s ``` Of course if you do load additional packages, the extra code does still need to be compiled, so e.g. building a system image for `Plots` goes from 3 mins to 1 mins (building all of plots, plus everything in base that got invalidated). That is still all in LLVM though - it should be relatively straightforward to multithread that after this PR (since linking the sysimg in multiple pieces is allowed). That part is not implemented yet though.
- Loading branch information
Showing
15 changed files
with
236 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.