-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Excise REPL and its dependencies from sysimg #51399
Conversation
Positive startup impact for But just |
function time_repl_startup(julia_cmd="./julia")
@async begin sleep(1); println("please press ^d") end
buf = IOBuffer()
t0 = time()
run(pipeline(`$julia_cmd --startup-file=no -ie 'atreplinit(_->println(time()))'`, buf))
s = String(take!(buf))
parse(Float64, strip(match(r"\n\n\d\.\d\d\d\d+e\d\n", s).match))-t0
end |
Another way suggested by Jameson iirc: just |
For me, "snappiness" refers to elapsed wall-clock time so reported user time might be misleading in the presence of CPU utilization other than 100% (either less or more). |
So the extra-overhead is coming from |
d509367
to
d829a18
Compare
d829a18
to
f9ef95e
Compare
Would be great if folks try this out on different machines and see if they think the latency is now okay. |
I tried this PR out. Julia's REPL itself does launch perceptably slower (perhaps 100-150 ms slower, but don't know how to measure it), but once the banner appears, the REPL is responsive immediately with no latency. |
f9ef95e
to
75014c5
Compare
So... it turns out my recommendation above underreports time till the "julia>" prompt appears because the Results:
Scriptfrom subprocess import Popen, PIPE, STDOUT
from time import time, sleep
import statistics
def repl_startup_time(exe):
sleep(.3)
t0 = time()
p = Popen(exe + " --startup-file=no", stdout = PIPE, stderr = STDOUT, shell = True)
str = []
end = "julia>"
while True:
out = p.stdout.read(1)
if out == b'':
raise RuntimeError("Unexpected end")
else:
str.append(out.decode("utf-8"))
if len(str) > len(end) and ''.join(str[-len(end):]) == end:
break
# print(''.join(str))
t1 = time()
p.kill()
sleep(.3)
return t1 - t0
def no_repl_startup_time(exe):
sleep(.3)
t0 = time()
p = Popen(exe + " --startup-file=no -e 'println(sqrt(2))'", stdout = PIPE, stderr = STDOUT, shell = True)
p.wait()
# print(p.stdout.read())
t1 = time()
sleep(.3)
return t1 - t0
def process(fun, exe, n):
data = [fun(exe) for _ in range(n)]
mn, med, mean = min(data), statistics.median(data), statistics.mean(data)
return "{:.0f}/{:.0f}/{:.0f}".format(1000*mn, 1000*med, 1000*mean)
print("system info:")
p = Popen("julia --startup-file=no -e 'using InteractiveUtils; versioninfo()'", shell = True)
p.wait()
print("master:")
p = Popen("julia/julia --startup-file=no -e 'Base.banner(short=true)'", shell = True)
p.wait()
print("pr:")
p = Popen("julia2/julia --startup-file=no -e 'Base.banner(short=true)'", shell = True)
p.wait()
process(repl_startup_time, "julia/julia", 3)
process(repl_startup_time, "julia2/julia", 3)
process(no_repl_startup_time, "julia/julia", 3)
process(no_repl_startup_time, "julia2/julia", 3)
print(" min/med/mean (ms)")
print("master repl: " + process(repl_startup_time, "julia/julia", 30))
print("pr repl: " + process(repl_startup_time, "julia2/julia", 30))
print("master no repl: " + process(no_repl_startup_time, "julia/julia", 30))
print("pr no repl: " + process(no_repl_startup_time, "julia2/julia", 30)) According to my measurements, this PR is great for startup times. It would be nice to include this sort of end to end startup time benchmarking in BaseBenchmarks.jl. |
I don't quite trust this... It feels slower, but maybe its more that I have a debug build on? |
One way to measure latency with REPL is to take a screen recording... |
What is your environment? This looks like you are missing |
@LilithHafner I made the debug message more useful. |
I usually record a gif and count the frames until I see the julia repl prompt. |
https://discourse.julialang.org/t/10-15-minute-ttfp-with-plots-jl-please-help/92636/53?u=lilith
Original source: JuliaLang/Pkg.jl#2669 (comment) Also if you could do `JULIA_DEBUG=loading`.
This fixes it, but my startup file is currently fine on master, so I think this is a regression of some sort. I'll try to distill my startup file to a MWE. |
It's particularly weird that we can load Pkg, but not REPL. Pkg depends on REPL. |
The culprit in my startup.jl file seems to be
|
A test case that covers this for me is running
at the command line. Does that test case fail on your machine too? Regardless, I'm not sure how to do this within Julia's testing framework. |
Okay loading Revise breaks the |
c7c81f4
to
e8fc317
Compare
# @which is undefined | ||
@test_broken v == ("false\nREPL: InteractiveUtilstrue\n", true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has introduced a distracting/confusing error show into CI
This reverts commit 2defa57.
Needs #51189 for proper precompilation of Pkg.
Moves the precompilation of the REPL into it's own pkgimg.
Similar to #51350, but without moving any code out of Base.