So much work has been done to improve julia compilation and remove invalidations. Things really feel a lot snappier to use.
But there is still the problem of packages that were written without much thought to startup time, and TTFX - the time-to-first whatever a package does most, is sometimes really slow.
Some common problems I see are (reorganised to be in order of importance):
- Lack of type stability slowing down compilation.
- Not calling
precompilefor common methods, or just running them if that is possible (see Chrisses comment below).
- Using Requires.jl so there is no code precompilation for the required code.
- Not checking or fixing compilation time of dependencies
Or simply that TTFX profiling has never been done, or was difficult in the specific context.
I have been as guilty of these things as anyone else, and I’m slowly trying to work on it in my own packages. But it seems there are problems in some widely used packages, and fixing these could really improve the experience of using Julia. We could all probably learn a bit more about how people are improving load times across the ecosystem.
I’m not singling anyone out, Blink is super useful. It’s just something I happen to use for a few things and would really like if it loaded quickly.
Blink.jl seems to be the default container for a Julia desktop web app. But it’s really slow to get started.
using Blink takes 5 seconds to load on my laptop, and loading an empty window with
Blink.Window() takes 11-15 seconds to finish the first time!! In comparison, vscode only takes 2 seconds to load in total, also using Electron.
It turns out startup time is largely due to Requires.jl blocks in WebIO.jl. It seems to be precompilation and JSON parsing in
Moving code out of requires in WebIO.jl gets the blink load time down to 1 second! Yes, a 5x improvement just from that.
Blink.Window() is harder, a lot of compilation in HTTP.jl and Mux.jl, slow JSON parsing in
JSON.parse, and various other things I’m not across. Maybe JSON3.jl would be faster? Maybe we can precompile all of this somehow? Maybe some profiling work on HTTP.jl would help? I’m not sure, but probably someone here has some ideas.
It could be faster and more fun to make a collective effort of speeding up startup time for common packages, also making the tricks more widely known. A bit like the performance workshopping we see here - can we get competitive about how fast we can make a package load and perform its most common operation?
We could also get together a list of packages that we all use that could be faster? and make it happen? or just have a common thread here like “TTFX: Blink.jl Window()”.
Thoughts on this generally? Or ideas for Blink?