dark
dark copied to clipboard
Stream back responses from analysis
When running analysis in the browser, we send back responses all at the end. This causes two problems:
- it might be too big
- users wait a long time for analysis to be finished, and in some cases way way way too long for it to be useful.
Could we instead stream responses back in some sort of batches?
Let's! As a first draft:
Whenever an analysis is complete, we only return
- the result of the full expression
- the result of the expression their text cursor is on, if any
Other results can be cached and either fetched on-demand later from the main thread, or slowly pushed to the main thread
finding a way to cancel requests when new ones come in would be great, too. We've discussed before, but revisiting would help the analysis snappiness.
Another sub-feature here: lists should be 'streamed' as well - only return the first x elements
The thing that makes the most sense to me is to send the value for each ID as it's produced. My sense is this is a relatively simple change, while caching it in the webworker seems complicated.
good point! ah, that sounds kind of fun.
Another sub-feature here: lists should be 'streamed' as well - only return the first x elements
This seems tricky. Serializing and transmitting lists is relatively fast compared to producing them - if they're large enough to cause problems serializing/transmitting, they probably crashed the analysis.
It also had some complicated features. We don't have a good way of storing sublists on the client, so this would be quite a large feature (example of the challenge: when someone presses execute, we use the saved analysis results. So we'd also need to handle what happens if someone wants to execute something on a partial list).
I'd wait for this until the need becomes apparent.
finding a way to cancel requests when new ones come in would be great, too. We've discussed before, but revisiting would help the analysis snappiness.
Would we need to add cancellation tokes everywhere for this? Doesn't seem nice, but might need to be done anyway.
Is there a way to tell a webworker to stop its job?
folded into #5237