-
Notifications
You must be signed in to change notification settings - Fork 59
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
Concurrent requests without Send
requirement for single threaded runtimes
#386
Comments
Thanks for opening this ticket, @dsherret! Just to clarify: the prototype introduced in #284 does execute requests concurrently wherever possible, provided their handlers take EDIT: Further detail may be found in this comment in particular: #284 (comment) |
Maybe this is just an issue with how our implementation is designed and we're doing it wrong, but it wouldn't work for us because within requests like All this said, having it be |
Would the client ever call back into the server while the server is held exclusively in a Most, if not all, LSP state modification flows as I understand them tend to go along this direction:
Is this not the case? |
FWIW, the necessary bar for marking a |
(Sorry, I said we never want to call back into the client in an Basically, the spec can say whatever it likes to prevent this, but what happens in practice with clients is not always according to the spec. We previously had deadlocks occurring because of this scenario, so we just never do it anymore and no longer have issues related to that for what I know (that said, the code previously used an async Mutex for every request instead of an async RwLock, so that was probably the main reason). |
I see what you mean, but none of the methods proposed in #284 to take Let's see how this might play out below... Server lifecycle messagesMethods like Considering that Text document & workspace state change notificationsWhether the The client is the one notifying the server of the state change, not the other way around. This means it should already have all the information it needs on hand already and should be able to respond immediately to any request the server sends, thereby avoiding the trap described in #386 (comment). This means it is impossible for the following example flow to ever happen:
Let's imagine that the client sends multiple As a bonus, this serial processing guarantees that any and all
All the above points considered, I'm fairly confident that these methods should be fine to mark Execute command requestThe final method marked The rationale behind this change stems from the presumption that command execution is expected to be synchronous: the command being executed might update state on the server side, or it might not. If the state is updated, then processing this request serially and exclusively relative to other pending requests is important (just like the Other candidates?Looking back at this helpful suggestion on Reddit by @matklad, I suspect there may be other (Please do correct me if I'm fundamentally misunderstanding some core assumptions about, not just the spec, but more the typical flows one sees in an average LSP interaction!) |
Apologies for the massive wall of text! ❤️ With that said, I'd be happy to continue discussion of the merits and drawbacks of supporting In the meantime, I'd be happy to split out the work in #284 into two separate parts if that would help? That is, I could draft a release of |
@ebkalderon sorry for my delay responding here and thanks for the overview! I think you're right that having
That would be extremely helpful! It would be great for us to be able to drop the |
In #284 there is some discussion about having
#[tower_lsp::async_trait(?Send)]
which I presume is a way to not have theSend
requirement on futures. That said, the change seems to execute the requests sequentially and have mutable methods. How feasible would it be to have the option to not have theSend
requirement and still execute requests concurrently for single threaded runtimes? Then the client can decide which requests should run sequentially or on a separate thread and also the code consuming this can useRc
andRefCells
instead of needing to useArc
andMutex
.The text was updated successfully, but these errors were encountered: