-
Notifications
You must be signed in to change notification settings - Fork 447
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
Path Deduping only works on subsets, not intersecting sets of paths #779
Comments
Possible relation to #819 |
@steveorsomethin so I remember this was actually pretty involved, but we did get it done in @graphistry/falcor in order to dedupe new requests against inflight partially-fulfilled streaming responses. IIRC we did it in this commit, though I think it also relied on some earlier work on the request queue to distribute paths across in-flight requests. From a high level, I think the process went like this:
Individually, a Request will keep track of the paths it's supposed to get. In the case of a pending Request (which batches multiple gets together), we can have a list of lists of optimized paths ( When a pending Request becomes an in-flight Request, materialize the list of lists of optimized paths into a list of PathMap trees, which we can use to compute the path complements for de-duping. Note: Our implementation has some logic specific to other changes we made for reusing the JSON output across get requests (essentially instead of That's most of what I remember, let me know if there's any more I can do to help! * correction edit - I meant requested missing paths, not optimized |
Thanks a lot for the detailed write up @trxcllnt. I previously had a look at that commit and it looked pretty intense, so this is very helpful. We'll probably tackle this one in the next couple of weeks. |
#897 takes a stab at this |
Currently path deduping only works if a set of requested paths is a subset of the paths in an outstanding request. However we'd like deduping to work in the event that a set of requested paths intersects with those in an outstanding request, with only the difference being requested from the server.
For example, a request for ["genrelists", {from:0,to:5}, "name"] will be deduped against an outstanding request for ["genrelists", {from:0,to:10}, "name"]. However the request for ["genrelists", {from:0,to:5}, "name"] will not be partially deduped against an outstanding request for ["genrelists", {from:1,to:4}, "name"], with only the difference being requested from the server (["genrelists", [0,5], "name"]).
When a batch of outgoing requests is being accumulated, it is modeled as an Array of Array of Paths. In other words two separate requests for ["genreLists", 0, "name"] and ["genreLists", 1, "name"] will be modeled like this in a batch:
When a batch is sent out, it is converted into a path map, making it efficient to check for intersections with other sets of paths:
Each outstanding request has a count indicating how many outstanding observers are awaiting the response. If all observer's unsubscribe, the count drops to 0 and the request is cancelled.
Currently the paths in each new request is matched against each outstanding request's PathMap. If the set of requested paths is a subset of an outstanding batch's set of paths, it is deduped and the number of observers listening for the batch is incremented. However if a set of paths merely intersects with those of the outstanding request, the algorithm gives up and creates a new batch for the paths.
The fix is to alter the algorithm to create a new batch for just the difference between the requested paths and the sets of paths that have already been sent to the server. Then it will be necessary to ensure that the request is only processed after all outstanding request dependencies (ex. ["genreLists", {from: 1, to: 4}, "name"] and ["genreLists", [0,5], "name"]) hey have been received from the server and merged into the cache. @trxcllnt Do you have anything to add to this?
@ktrott @steveorsomethin @sdesai @lrowe
The text was updated successfully, but these errors were encountered: