Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make julia + repl start twice as fast [do not merge] #28075

Closed
wants to merge 2 commits into from

Conversation

KristofferC
Copy link
Member

@KristofferC KristofferC commented Jul 12, 2018

I compiled julia with #define TRACE_COMPILE, started ./julia 2 > precompile.txt, copy pasted the output into precompile.jl. Note that anonymous functions are kept. I recorded time to start julia, and also recorded the number of frames (60 FPS) until the banner and prompt showed.

Before PR:

➜  time ./julia -e 1+1
./julia -e 1+1  0.38s user 0.14s system 149% cpu 0.352 total
➜  time ./julia -e 1+1
./julia -e 1+1  0.38s user 0.14s system 149% cpu 0.347 total
➜  time ./julia -e 1+1
./julia -e 1+1  0.39s user 0.15s system 149% cpu 0.359 total
14 frames banner
32 frames prompt

After PR

➜ time ./julia -e 1+1
./julia -e 1+1  0.22s user 0.12s system 113% cpu 0.293 total
➜ time ./julia -e 1+1
./julia -e 1+1  0.21s user 0.12s system 113% cpu 0.292 total
➜  time ./julia -e 1+1
./julia -e 1+1  0.22s user 0.11s system 111% cpu 0.289 total
13 frames banner
17 frames prompt

0.6.4

➜  time julia -e 1+1
julia -e 1+1  0.31s user 0.11s system 122% cpu 0.339 total
➜ time julia -e 1+1
julia -e 1+1  0.30s user 0.10s system 123% cpu 0.328 total
➜  time julia -e 1+1
julia -e 1+1  0.30s user 0.10s system 121% cpu 0.335 total
12 frames banner
27 frames prompt

So time ./julia -e 1+1 is approx 70% faster, and the time until the REPL prompt shows is approx 90% faster with this PR vs master. Also significantly faster vs 0.6.

— But won't these anonymous functions go stale quickly?
— Yeah maybe, but let's just have them in for the release then, and then revert the commit or something.

— But won't these anonymous functions be different on different systems?
— Yeah, if different functions are defined on different systems, the precompile list from one system is not directly transferable. Needs something like #26503 to deal with that.

I also have a commit that does the same thing, but in addition, does some moving around in the REPL and it feels awesome to use. But one thing at a time.

@KristofferC KristofferC added the compiler:precompilation Precompilation of modules label Jul 12, 2018
@KristofferC KristofferC force-pushed the kc/anonymous branch 4 times, most recently from 9ad3d7e to 0806301 Compare July 12, 2018 10:43
@mauro3
Copy link
Contributor

mauro3 commented Jul 12, 2018

Does this also increase response time to first key press? At the moment there is a noticeable lag.

@KristofferC
Copy link
Member Author

Yes if I do

I also have a commit that does the same thing, but in addition, does some moving around in the REPL and it feels awesome to use. But one thing at a time.

it is instant.

@KristofferC
Copy link
Member Author

KristofferC commented Jul 12, 2018

I made a little script that makes this easy to do at home if you build from source: https://gist.github.com/KristofferC/a8a70f4bddafa068d19fd21d40c9015c. Could probably be done similarly to the build_sysimg script but this was easier for now. Execute it from the julia directory.

It contains two version. One that requires two recompilations but manages to catch the whole startup process, and one that only requires one recompilation but misses a bit (loses about 0.1 second startup for me).

Would be interesting to hear any results (if it works...)

@KristofferC KristofferC changed the title Make julia + repl start twice as fast Make julia + repl start twice as fast [do not merge] Jul 12, 2018
@KristofferC
Copy link
Member Author

I added a commit which did a few actions in the REPL just to see if it passes CI.

@KristofferC KristofferC added the triage This should be discussed on a triage call label Jul 12, 2018
@KristofferC
Copy link
Member Author

Putting a triage label so we can discuss if we want to try something like this for the release / beta. Personally, I think the performance improvements are definitely worth it. I can take responsibility for it.

@KristofferC
Copy link
Member Author

KristofferC commented Jul 12, 2018

Triage thought this needs to be automated and we should work towards that instead (pretty much exactly #26503). I've tried this a bit before but I didn't know enough about pipes, TTYs etc to be able to record and replay a REPL session. I'll see if I can get some time to work on it but grateful for any help. Getting this working would be very because I do think the impact is quite large.

For those who want this now it is quite easy to use the script I posted a few posts up.

@KristofferC KristofferC removed the triage This should be discussed on a triage call label Jul 12, 2018
@vtjnash
Copy link
Member

vtjnash commented Jul 12, 2018

Superseded by #28065?

@KristofferC
Copy link
Member Author

KristofferC commented Jul 12, 2018

If you have checked that the startup and time to prompt is the same as with this PR, then yes. From my testing, that PR didn't do much to either of them.

Edit: I tried again and even with a new precompile file on that PR, it didn't seem to affect startup at all, so not sure how that supersedes it. Perhaps you can elaborate @vtjnash?

@maleadt
Copy link
Member

maleadt commented Jul 13, 2018

I was using this when creating the graphs from #23006 (comment)

@KristofferC
Copy link
Member Author

A short animation of starting + restarting julia with this PR and then with the beta:

https://asciinema.org/a/hMmHsdvVxqhQTkcO60uz1c23U

@KristofferC
Copy link
Member Author

Closing in favor of #28118

@DilumAluthge DilumAluthge deleted the kc/anonymous branch March 25, 2021 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:precompilation Precompilation of modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants