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

remove time + pessimistic_sleep #45

Closed
wants to merge 1 commit into from
Closed

Conversation

SimonDanisch
Copy link
Member

this will remove the time attribute from a scene, since this was always waking up the whole event loop.
Removing it decreased the time spent on the cpu from ~20% to ~0 cpu usage for idle time.

I'd say, people should just implement their own loop for doing animations relying on the time.
cc @jpsamaroo
@ssfrr, what do you think, you used scene[:time] so far.

@ssfrr
Copy link
Contributor

ssfrr commented Jan 10, 2018

I used it assuming it was doing something clever on the GPU, if that's not the case then there's less motivation for it.

It does seem like there should be an easy way to do realtime animations in a way that's synchronized with the frame-rate, and having a scene[:time] signal that's updated every frame seems like one reasonable way to do that. Honestly though I'm still trying to wrap my head around what idiomatic Makie code should look like, mostly with regards to the FRP bits (e.g. when to use a signal vs. a loop that just updates things in the scene).

@SimonDanisch
Copy link
Member Author

I think, the most idiomatic code should look like this:

while isopen(scene) # or whatever loop, event callback one wants to chose
    scene[:value] = newvalue
   ...
# or recordframe! or actually just a yield() which should, but is not guaranteed, to yield to renderframe in the actual renderloop
   renderframe(scene) 
end

@jpsamaroo
Copy link
Contributor

I still need to try this out locally, but thanks for addressing this so quickly! I do feel that the burden of animations should be on either the user or some other package, since the decision of when to yield and render can vary based on the situation, so this makes sense to me!

@SimonDanisch
Copy link
Member Author

yeah it should be programmed to at least opt out in some way.. not sure if we could get the best of both otherwise

@jpsamaroo
Copy link
Contributor

Just confirmed that this branch brings down CPU load to about 1% or less in htop. Great work!

@SimonDanisch
Copy link
Member Author

I was thinking, I could check if time has any registered observers... But I'm not sure if I want this kind of special treatment and check every loop iteration ;)

@SimonDanisch SimonDanisch deleted the sd/efficientloop branch May 18, 2021 09:39
SimonDanisch added a commit that referenced this pull request Jun 3, 2021
SimonDanisch pushed a commit that referenced this pull request Jun 3, 2021
SimonDanisch added a commit that referenced this pull request Jun 3, 2021
@chriswaudby chriswaudby mentioned this pull request Feb 12, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants