dark icon indicating copy to clipboard operation
dark copied to clipboard

Stream back responses from analysis

Open pbiggar opened this issue 3 years ago • 7 comments

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?

pbiggar avatar May 27 '22 14:05 pbiggar

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

StachuDotNet avatar Jun 09 '22 03:06 StachuDotNet

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.

StachuDotNet avatar Jun 09 '22 03:06 StachuDotNet

Another sub-feature here: lists should be 'streamed' as well - only return the first x elements

StachuDotNet avatar Jun 09 '22 03:06 StachuDotNet

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.

pbiggar avatar Jun 09 '22 03:06 pbiggar

good point! ah, that sounds kind of fun.

StachuDotNet avatar Jun 09 '22 03:06 StachuDotNet

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.

pbiggar avatar Jun 09 '22 03:06 pbiggar

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?

pbiggar avatar Jun 09 '22 03:06 pbiggar

folded into #5237

StachuDotNet avatar Jan 09 '24 20:01 StachuDotNet