marimo
marimo copied to clipboard
Reduce (again) refresh rate
Description
Hello,
Following #833
MQTT telemetry in Python / Marimo notebook works pretty well but
mo.ui.refresh value is still a bit too big
Any opinion?
Suggested solution
It's currently 100ms.
A Matplotlib scatter plot is taking 17 ms to be executed so we could have 58 fps !
25 fps so a minimal refresh of 0.04s will be fine
https://github.com/marimo-team/marimo/pull/837/files#diff-7f057d77609560560e7b7db4cbdce6af36dd23e08036f5fdd6e1f9eb7771faf4R32
defines a 0.1 s refresh interval
but 0.04 s would be much better (because of persistence of vision)
Alternative
No response
Additional context
No response
You are going to incur a network request, parsing etc by using mo.ui.refresh
. I feel like that might not be the tool to use. Instead, I would suggest keeping this all in python with a while/for
loop and if you need, you can put a sleep in there.
For example, check out this notebook: https://marimo.app/l/roy6wo
That's a nice example but I don't see a while loop but a for loop and that's main problem...
Try with your example to add a cell when simulation is running and execute a simple calculation (1 + 2 for example). You will notice that the new cell is executed only when cell with for loop have finished its task. This is why this example doesn't really help as I should be using a while loop to refresh my plot infinitely (at least until notebook is running)... this will lead to have no more "active" cell. Do you see what I mean?
Do you think I can use a threading.Thread which will be responsible of refreshing Matplotlib plot (and see result in a cell)?
With Pluto.jl Clock doesn't have such a limitation a can be equal to 0.04 ... but I'd prefer to keep same language on both side of my project ie on robot side and on pc telemetry side (so Python is needed)
You can try even with 0,00001 on their website! with 0,000001 variable t doesn't increase... but with 0,00001 it increases pretty well!
That's a nice example but I don't see a while loop but a for loop and that's main problem...
Try with your example to add a cell when simulation is running and execute a simple calculation (1 + 2 for example). You will notice that the new cell is executed only when cell with for loop have finished its task. This is why this example doesn't really help as I should be using a while loop to refresh my plot infinitely (at least until notebook is running)... this will lead to have no more "active" cell. Do you see what I mean?
Do you think I can use a threading.Thread which will be responsible of refreshing Matplotlib plot (and see result in a cell)?
With Pluto.jl Clock doesn't have such a limitation a can be equal to 0.04 ... but I'd prefer to keep same language on both side of my project ie on robot side and on pc telemetry side (so Python is needed)
You can try even with 0,00001 on their website! with 0,000001 variable t doesn't increase... but with 0,00001 it increases pretty well!
I tried Pluto.jl with 0.001 seconds per tick, and it does seem fine at least for simple use cases. Maybe we should look into this