-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Core Improvement] Reign in the amount of content sent to the frontend client when things are updated. #395
Comments
@JackUrb I would like to help with this |
Hi @xssChauhan - this is a fairly involved change that I've already started work for, but one segment I haven't touched is the last part (the hashing step). This involves sending a request from the web client to a new endpoint with an env id and window id and receiving in return a hash/checksum of the layout and data of that window. You can then also implement the same hash/checksum function on the web side. Does this seem like something you'd want to work on? |
@JackUrb This is certainly interesting. Would be glad to work on it. Where do i begin? |
Alright so you'll start in the server file by introducing a new endpoint. This should be something like the exists handler: https://github.com/facebookresearch/visdom/blob/ec91e738e100a9cbf946c332c7783ffd12c644b5/py/visdom/server.py#L155 |
@JackUrb Understood. Is there a branch for this already? Or do i make one from master only? |
You can start a new branch for this - it's somewhat independent of the rest of the work |
Cool. Getting started now. Thank you for the starting pointers. |
@JackUrb Here's my implementation for the hash handler. Will you please take a look at it and tell me your review? |
@xssChauhan - feel free to open it as a pull request and I can better comment there! |
@JackUrb Shall i also add a function to get the hash of window in visdom/init.py? This function would be similar to |
We actually need the function in both |
The one in init should call the server endpoint, the one in main should perform its own hash |
Yup, that would work! |
@JackUrb Just so that my understanding is clear, for the JS side, we need implementation for the following:
This would then enable the web client to decide if the there is change in the content of a window by comparing the local and server hash. Then the client can decide to fetch the new changes. Is my understanding correct? |
Yup that's the idea |
Window hashing is implemented in #422. Next step is more complicated: determining the difference in json that is going to be created by an update or post. This would amount to creating an update package for what happens to In the UpdateHandler: https://github.com/facebookresearch/visdom/blob/52c453a885836a9449056315d6452ad9a66ce115/py/visdom/server.py#L527 In the PostHandler: https://github.com/facebookresearch/visdom/blob/52c453a885836a9449056315d6452ad9a66ce115/py/visdom/server.py#L489 This is going to have to be created as a python dict that will convert to JSON. The implementation for this update packet is up to you. Below is a sample for a possible update packet implementation for inserting a trace:
Or for deleting a trace (that with idx 3 in the array):
You can test by logging the |
@JackUrb Thank you for providing the details. I shall have a look and then get back. |
@JackUrb Just to make my understanding clear: For UpdateHandler, we need to update the This can be achieved by comparing the incoming data with the existing data on the handler and then mark the changes in the packet as well. |
Hi @xssChauhan - I've done a bit of research since last posting that. I'm going to describe the new set of steps for the overall goal of this core improvement. The simplest implementation here will be to create a diff between the old json representation of a plot and the new one. This
At this point no individual step of this will be self contained, the whole thing will need to be implemented to merge it, but if you get started on this path you can open a PR and then I can contribute as well whenever I get a chance. |
@JackUrb Thank you for describing in detail. I shall get started, and open a PR soon. We can have further discussions there. |
Maybe it will help (for other contributors) to elaborate what is the state of this PR and what is still missing. Also, is there a benchmark showing that the sending/receiving of diffs is worth the computation overhead introduced in this PR (hashing / calculating diff / applying diff etc.)? |
@amitibo Of course. The current state of this development is as follows. There now exists infrastructure to ensure parity between the server and the frontend client at each update by creating and comparing hashes of the data for an object. This means that the consistency checks are in place to move towards sending plot updates rather then the entirety of the plot data when something changes. There are 2 primary ways that this can be implemented.
I haven't benchmarked this change, but now that we have webgl support for plots with huge amounts of points in #431, and I'm trying to introduce image data over time in #393, and we've already seen data send issues on long running servers with large plots in #386, I'm fairly confident that the IO gains would be worthwhile. The change would also expose logic on the frontend for applying specific updates to plot data, which should help expose a way to solve longtime issue #171. |
@JackUrb maybe you have some example json files that can demonstrate such a situation, or an example (python) script that creates such files? It can help in debugging/testing/benchmarking this change. |
Also, I understand that there is a problem finding a |
Implemented in #552 |
Summary: Closes #286 by implementation. Fixes #369 for real. Adds a way to store image history. The `store_history` option, when provided repeatedly for the same window will allow for appending multiple images to the same pane, accessed using a slider. The most recently sent image will be selected by default, and updates from the python client will reset the selection to the most recent. This doesn't break any existing behavior: <img width="1271" alt="screen shot 2018-06-19 at 5 42 28 pm" src="https://user-images.githubusercontent.com/1276867/41627014-87e384ac-73ec-11e8-85bc-f3473f5f8ca3.png"> This also begins the process for adding 'widgets' to arbitrary panes, allowing for functionality like long requested in #25. (Standardizing these widgets and allowing users to attach them to variables in the plot/layout state will be the last part of implementing #25) Full implementation flow: - Adds an option to `image` that attaches a store_history option to the request. Sends the request to the update endpoint if the window already exists. (Note: It'd be nice to make it so that the server doesn't require the `store_history` flag every time an additional image is sent, but it complicates the flow a lot. May revisit down the road) - Creates flows in the create and update handlers of the server that recognize `image_history` types and append data to the content rather than making it new. - Adds logic to `ImagePane` that allow them to track the state of the slider, if it exists - Adds logic to `Panes` that allows specialized panes to render additional content 'widgets' at the bottom of the pane. Gotchas: - ~~This PR doesn't have a demo, will include in a follow-up~~ Added in #593 - This PR doesn't have feedback sent back to the python client on slider updates, will implement in a follow-up - This PR doesn't have a method for the python client to select a slider value, will implement in a follow-up alongside a demo that can sync the contents of multiple image panes to one slider! - ~~This PR brings up the issue of the size of content being sent during window updates to a head, as each additional image added to a history forces a send of the entire history every single time. Furthermore each update to any window in the same environment will force this same send.~~ This was implemented in #395 - This PR doesn't properly handle margins, even though I can calculate how tall I want them to be. Need to review some CSS magic. <img width="1268" alt="screen shot 2018-06-19 at 5 50 16 pm" src="https://user-images.githubusercontent.com/1276867/41627411-3652d406-73ee-11e8-86b5-5236ebff6b28.png"> Pull Request resolved: #393 Differential Revision: D14787240 Pulled By: JackUrb fbshipit-source-id: 6452df6b12b759030efaa254a4cf3f2d4aadb724
Noted in #393, a lot of data gets sent to the client as an environment grows. As seen in #386, this is not a sustainable practice. Moving forward we'll need to be able to send update packets from the server rather than the entire contents of an environment's json every time a window in that json gets updated. The client should only request the complete contents when the environment changes or if an inconsistency is detected (can be done using a hash of the stored data).
The text was updated successfully, but these errors were encountered: