There’s a lot of benchmark scripts out there right now where Julia is at a big disadvantage due to compiler overhead and such. Has anyone thought out an easy way that we can start taking advantage of pkgimages to reduce this compilation overhead in various benchmarks?
Having to bundle all of the user’s code into a
dev’d package seems a little heavy. E.g. in the example of n-body Julia #8 program (Benchmarks Game) could we make this significantly faster by bundling the code into a pkgimage, and if so what would be the most elegant way to do that?
I asked this question two months ago in the
#ttfx channel on Slack and it went unanswered
It’d be nice if we had a way to build “scriptimages” which were just a wrapper around a pkgimage that could be invoked by julia from the command line in a similar way to a script.
For what it’s worth, I just tried taking the above linked script and shoved it in a little
dev’d package, removed the interactive part and added
function main(N = parse(Int, ARGS); bodies=bodies)
# This will let SnoopPrecompile AOT compile all the machine code we need to just call `main()` from a script.
_bodies = copy(bodies)
The timings I got on my machine using the original script was
and now using the precompiled pkgimage to invoke
main() I get
So almost a 20% speedup of the wall time. If they got a 20% wall time speedup in the benchmarks posted: n-body (Benchmarks Game) julia would actually be the fastest language shown.