-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add a rate limiter on the slicer's index #24
Conversation
bdd6a75
to
e670173
Compare
It looks like there is a problem with the CI. |
a3b46b2
to
2a4af1c
Compare
Ready for review! |
Co-authored-by: Emmanuelle Gouillart <[email protected]>
) | ||
def upload_requested_slice(slice_index): | ||
slice = img_array_to_uri(self._slice(slice_index)) | ||
return {"index": slice_index, "slice": slice} | ||
|
||
def _create_client_callbacks(self): | ||
"""Create the callbacks that run client-side.""" | ||
|
||
# setpos (external) |
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 is some serious Ascii art :-)
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.
I'm eager for better ways to use diagrams to document code. In the mean time, ASCII art it is :)
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.
http://blockdiag.com/en/ maybe... (usable as a sphinx extension from a "sphinx documentation diagram" Google search :-), did not investigate more).
This looks great, feel free to merge when you want (I read the code quicky but I can read it in more details when it's merged as well, and I agree that this rate limitation mechanism is a good thing for performance). |
Following up on #23, this PR improves the user experience by trying to keep the effect of a fast-changing index local to the current slicer. While dragging the slider, the current slicer is updated, but the other slicers (for the same scene_id) are not notified, nor will there be a request for new data to the server. When you stop dragging, the final value is "published", so the indicators update and the server provides the full-res data. This means all CPU cycles can be used to keep the current slicer responsive.
This is implemented using an Interval object that is turned on when the slider value is changed, and turned off when the value is published. The interval can be set to just 100ms so there is no perceived waiting time. Note that the behavior is pretty similar to the proposed approach in plotly/dash-core-components#884.
In this PR:
slider.value
is rate-limited (with a dcc.Interval) into a store called "index".reverse_y=False
, and don't use it in our examples (for now).