-
Notifications
You must be signed in to change notification settings - Fork 946
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
Implement update echo messages in a backward-compatible way #3392
Comments
In other words, I'm suggesting that the protocol be amended this way: Synchronizing multiple frontends:
|
CC @tkrabel-db |
Discussion points from today's dev meeting:
|
Sounds solid, I'm in favour of putting this in 7.7, possibly off by default? |
@maartenbreddels already did some good work on this, much appreciated. |
Yes, I think we should default off in 7.7, and probably default on for 8.0. |
I'm working through a PR on this, and I think we can consolidate the property_lock logic a bit too. Here is my current working draft of the logic:
|
I think I am way overthinking this. Here's a much simpler design:
|
…ate messages Starts fixing jupyter-widgets#3392
One thing I like about the simpler design is that it preserves the order of updates: you first get the update the kernel is applying, and then you get any updates in response from the kernel. If we were just sending the echo updates after the kernel processed the update, we would get the kernel updates first, then other attribute echos. |
For what it's worth, I find the simpler design very elegant :) |
As described in jupyter-widgets#3111 it can happen that a frontend can get out of sync due to not echoing back messages from the frontend. Widgets can opt out of this behaviour if it is too costly and/or does not make sense, e.g. the data from the file widget. Fixes jupyter-widgets#3111 avoid echo/jitter in frontend put jupyter echo behaviour behind a flag minimize diff remove spacing prettier lint fix: handle messages correctly when echoing disabled minimize diff minimize diff fix and test fix test, do not use set (no determinstic order) fix: echos from other clients are not unexpected comment and reformat better variable name Work-in-progress update for echo updates to have their own key in update messages Update protocol description Update js echo logic to handle echo_state key Starts fixing jupyter-widgets#3392 WIP consolidating logic for property lock. WIP simple reflection immediately on setting state. WIP Remove code about sending echo messages combined with any kernel updates Remove comments and simplify so the final diff is simpler Add debug test runner Experiment making echo updates a separate message Bump widget protocol version number back to 2.1.0 Update no_echo metadata name to echo_update for clarity. Having a negative in the name was confusing to me, so I renamed the property echo_update. Set it to False to disable echos for that attribute.
I think we can implement the update echo feature from #3195 and further discussed in #3343 in a backward-compatible way.
To summarize, when the kernel receives an update message, it will apply the message and then always broadcast out a message to clients, where some of the attribute updates in the broadcast message may be designated as echoed updates. Clients ignore echoed updates until their own update is echoed back to them. They should ignore because it lets them optimistically update their own UX. Essentially, seeing the echo of their own update lets them know the order in which the kernel is applying updates from multiple clients, and ignore those echoed updates if it knows that the kernel still has to apply its own update.
If a client does not ignore echo updates until it sees its own update echoed, and if the client is optimistically updating its own UX to reflect its update, we will have jitter. For example, imagine two clients displaying the same slider model, and both sliders are being dragged, and slider A sends a message updating the value to 5 while slider B sends a message updating the value to 10. Each slider is updated to its own update value, but we don't have consensus on what the kernel is going to pick. The kernel processes these messages in order, and sends out slider A's update as an echo, then slider B's update as an echo. Slider A receives its own echoed update, then B's echoed update, and applies B's update since it came after its own echo. However, slider B receives A's echoed update and ignores it, since it knows the kernel has yet to apply its own update. Then slider B receives its own echoed update, which it can ignore since it has already updated the UX optimistically for that value. The end result is that both clients and the kernel have agreed that B's update wins.
We said this protocol wasn't backwards compatible since if B doesn't know to ignore comm echo updates, it will jitter since it will apply A's update, then apply its own echo update. The real problem, though, is that the echo updates and normal updates are intermingled in the single key in the update message, so a client that doesn't know about comm echo updates cannot distinguish between the two types of updates.
However, what if we send echoed state updates in their own
echo_state
key, rather than conflating it with the normalstate
key for normal updates from the kernel? Then I think things are backwards compatible - clients that don't know about the echoed updates will ignore any echoed updates, so there is no change in their behavior. Clients that understand the echoed update messages can implement this consensus protocol from above. I think in this case, we can implement this logic in 7.7, to give it to people that won't be able to update to 8.0 right away.Disclosure: At Databricks, my current employer, we'd like to get this feature in 7.7 if we can, which led me to reevaluating the problem to see if there was a way we could do it in a backwards compatible way.
The text was updated successfully, but these errors were encountered: