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

Add a rate limiter on the slicer's index #24

Merged
merged 11 commits into from
Dec 2, 2020
Merged

Add a rate limiter on the slicer's index #24

merged 11 commits into from
Dec 2, 2020

Conversation

almarklein
Copy link
Collaborator

@almarklein almarklein commented Nov 25, 2020

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:

  • The slider.value is rate-limited (with a dcc.Interval) into a store called "index".
  • Renamed some of the private stores, reordered them, and add more documentation for them.
  • Add note in docs about performance of reverse_y=False, and don't use it in our examples (for now).
  • Turn of the part of debugging mode that mad things slow :)
  • More tweaks
  • Remove caching, made Caching of full-res slices clientside #27 to track for future

@emmanuelle
Copy link
Contributor

It looks like there is a problem with the CI.

@almarklein almarklein marked this pull request as ready for review November 25, 2020 19:28
@almarklein
Copy link
Collaborator Author

Ready for review!

dash_slicer/slicer.py Outdated Show resolved Hide resolved
Co-authored-by: Emmanuelle Gouillart <[email protected]>
This was referenced Dec 1, 2020
Closed
)
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)
Copy link
Contributor

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 :-)

Copy link
Collaborator Author

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 :)

Copy link
Contributor

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).

@emmanuelle
Copy link
Contributor

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).

@almarklein almarklein merged commit 893d0e2 into main Dec 2, 2020
@almarklein almarklein deleted the ratelimit branch December 2, 2020 10:04
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.

2 participants