Skip to content
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

Support canceling requests and drop superseded server requests #347

Closed
TitanNano opened this issue Oct 26, 2017 · 1 comment
Closed

Support canceling requests and drop superseded server requests #347

TitanNano opened this issue Oct 26, 2017 · 1 comment
Milestone

Comments

@TitanNano
Copy link

TitanNano commented Oct 26, 2017

Sometimes queries and re indexing are slow, this causes several auto complete and call tip requests to get queued up. Which in turn then causes me to wait until all requests are handled by the integrator core, one by one.

It would be much better, when outstanding requests of the same kind would be canceled and only the latest one of them handled.

@Gert-dev
Copy link
Owner

Agreed, though we have to make a distinction between two types of requests here:

  1. Requests that are going to be sent by the client (this package) and that can be debounced
  2. Requests that have already been sent to the server and that need to be canceled afterwards

The former already happens in the base package for (re)indexing requests and also for signature help; they will wait a while until things stabilize before sending a request to the server. Once that happens, however, it is "too late" to take them back.

This brings us to the latter. Currently, core 3.0 does not internally queue any requests and just takes them from the socket, processing them one by one. As such, canceling requests is pretty much impossible as they are still floating in the socket and the core is processing the events before any cancel request first, including the one that is supposed to be canceled.

Coincidentally, however, I've already updated the core to drain the socket as fast as possible and queue the requests separately. This means that in theory, it is now possible to support request cancellation in the core and base client. (IIRC, the language server protocol also added this in version 2.)

To summarize, this is something I want to do sooner or later, and it requires support in both the core and the base package.

@Gert-dev Gert-dev changed the title Drop superseded server requests Support canceling requests and drop superseded server requests Oct 26, 2017
Gert-dev added a commit that referenced this issue Jan 4, 2018
Gert-dev added a commit that referenced this issue Jan 25, 2018
With the queue, the first reindex request for a series of them was
always sent and left to be handled completely, whilst only the last of
any subsequent requests was maintained in order to skip unnecessary
intermediate ones. This way the core did not have to play catch up.

The unfortunate part was that the first reindex request always went
through, even if the core was very busy handling other requests and
could not handle that first request until a while later, after which
that first request might also have been superseded. As the request had
already been sent, however, there was no way to cancel it.

As the core now has request cancellation support, it is simpler to let
all reindex requests pass through to the core and just cancel the ones
that aren't relevant. This automatically allows us to cancel even the
first request, at least if it wasn't being processed yet - but that was
also the case before.

In short, this should improve latency on slower hardware where many
actions are being performed simultaneously.

References #347
@Gert-dev Gert-dev added this to the 3.2 milestone Jan 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants