-
-
Notifications
You must be signed in to change notification settings - Fork 311
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
Slow REPL together with Makie #267
Comments
The Julia REPL runs in a julia So whether the REPL Task will get enough resources to feel responsive depends on how good the rendering backend is at sharing the CPU. At the moment this is done here for GLMakie: https://github.com/JuliaPlots/GLMakie.jl/blob/6ea449dd1bd7878831e7086a7f20afd9e16f5b30/src/rendering.jl#L11. From the look of this, if you have a scene which isn't meeting the target framerate, the REPL task will be scheduled only once every frame. This could be due to CPU work (ie, scene preparation due to animation etc), and there's not a whole lot which can be done about that in current julia. Other than maybe adding a few more calls to Alternatively it could be due to CPU blocking while the GPU does work. Ideally we'd send all the work to the GPU and then release the CPU to do other things while we're waiting. OpenGL is generally asynchronous like this but there's certain things which force it to be synchronous, such as reading rendered frames back. For example when selecting objects by using |
I think it usually happens after call to resize!() (try e.g. resize!(scene,(3000,3000)) |
Do you even need a renderloop then? |
Probably not really. It's nice to see the results of what is rendered on the screen now and then, but it isn't a big issue if I have to save them somewhere and then inspect. |
What would happen if you started julia with |
It would be fairly simple to only render a frame on display, which should completely avoid this issue... need to figure out a nice API! Any recommendations are appreciated ;)
Pretty sure that nothing will happen... How do you get the idea that something should happen? |
Dang. Just thought of it from @c42f's comment about processes sharing a thread, so I thought if you allowed Julia more threads it could split the processes. |
For an API, how about having something like a constructor "Scene(;renderloop=[true|false])". In the case that |
@natschil could you share an MWE? I just compiled the latest build of Makie, and I'd like to test it out. |
I can't seem to reproduce it on my laptop at the moment, I'll try to reproduce it on a workstation where I've seen problems tomorrow. |
This is how things should work but julia's Task system is not multithreaded yet, and won't be until JuliaLang/julia#22631 (or equivalent) is merged. |
I have the same REPL slowness here even with fairly small, simple plots. Using Julia v1.5.0-rc2, AbstractPlotting v0.12.5, GLMakie v0.1.8, on a 2020 macbook pro, running this MWE plot takes 13 seconds for just printing using AbstractPlotting
using AbstractPlotting.MakieLayout
# Some data
x, y = 0:0.01:2π, 0:0.1:10
f(x,y) = (cos(x) + y > 9) ? NaN : cos(x) * sin(y)
data = [f(x,y) for x in x, y in y] ;
# A function to plot
function myplot(x, y, data)
scene, layout = layoutscene(10, resolution = (300, 300))
ax = layout[1,1] = LAxis(scene)
heatmap!(ax, x, y, data)
ylims!(ax, (10,0))
return scene
end
# GLMakie plot
using GLMakie; GLMakie.activate!()
display(myplot(x, y, data))
# time to print at REPL:
@time println(rand(20,20)) # takes 13.4 seconds |
This issue has gotten worse since we started using vsync. You can turn that off by setting |
EDIT: This works! The time-to-print has gone back to normal! Maybe make revert this change? (Thanks @ffreyer, you were correct, I had not closed the window!) |
You have to close the window for this to take effect |
This should be fixed by render on demand |
I'm currently using Makie with quite elaborate scenes in high resolution. I've found that sometimes stdin/stdout in the REPL is very, very slow if there is a scene window open (like every character takes a fraction of a second to be output, which is frustrating for long Julia errors). Julia itself is still fast, just the REPL is slow.
The text was updated successfully, but these errors were encountered: