Skip to content

concurrency bug fixes/ improvements #4663

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MangoIV
Copy link
Contributor

@MangoIV MangoIV commented Jul 16, 2025

Hi. I have two concurrency bug fixes/ improvements that pave the way towards multi client haskell-language-server.

  1. [fix] don't bake ide state mvar into setup and getIdeState
    This is the right thing to do because othewise it is not possible to
    create new ideStates in a single instance of the executable. This will
    be useful if the hls executable is supposed to talk to multiple clients
    and lives beyond a single client disconnecting

  2. [fix] don't throw hard errors when no shutdown message is handled
    Previously, when there was no shutdown message by a client and the
    client disconnected, resulting in the handlers to be GC'd the race that
    was supposed to free resources for the HieDB & co. would throw a hard
    error talking about the MVar being unreachable. We would like to instead
    finish gracefully because finishing the race as soon as the MVar was
    GC'd is the right thing to do anyway.

@MangoIV MangoIV requested a review from wz1000 as a code owner July 16, 2025 13:13
@fendor
Copy link
Collaborator

fendor commented Jul 17, 2025

The second commit seems to be neither a bug fix nor a concurrency improvement.
However, as the change is benign, it seems fine to me.

@MangoIV
Copy link
Contributor Author

MangoIV commented Jul 17, 2025

It doesn't appear to be one as of now ;)

Later when we create multiple clients per run of the executable, it's important that we can create multiple ide states, too.

@fendor
Copy link
Collaborator

fendor commented Jul 17, 2025

Right, as of now it is a random change :P

As you know, I don't think the complexity that might be introduced by handling multiple clients at the same time should be handled within HLS. Perhaps if the complexity was encapsulated in a separate module / executable.
In any way, we can discuss this in detail once you created a ticket :)

@MangoIV
Copy link
Contributor Author

MangoIV commented Jul 17, 2025

Well this complexity is necessary if we ever want a single executable with multiple clients which I think is actually required to make it feasible at all, mainly wrt memory footprint.

@MangoIV
Copy link
Contributor Author

MangoIV commented Jul 17, 2025

I'll create a ticket.

@MangoIV
Copy link
Contributor Author

MangoIV commented Jul 17, 2025

@fendor so whether or not I create the ticket, are these changes controversial?

@fendor
Copy link
Collaborator

fendor commented Jul 17, 2025

No, these changes are not controversial

This is the right thing to do because othewise it is not possible to
create new ideStates in a single instance of the executable. This will
be useful if the hls executable is supposed to talk to multiple clients
and lives beyond a single client disconnecting.
@MangoIV MangoIV force-pushed the mangoiv/concurrency-bug-fixes branch from dc9b008 to 5e7ee92 Compare July 26, 2025 14:53
Previously, when there was no shutdown message by a client and the
client disconnected, resulting in the handlers to be GC'd the race that
was supposed to free resources for the HieDB & co. would throw a hard
error talking about the MVar being unreachable. We would like to instead
finish gracefully because finishing the race as soon as the MVar was
GC'd is the right thing to do anyway.
@MangoIV MangoIV force-pushed the mangoiv/concurrency-bug-fixes branch from 5e7ee92 to 6696657 Compare July 26, 2025 21:27
@MangoIV
Copy link
Contributor Author

MangoIV commented Aug 2, 2025

@wz1000 @fendor can I get another review pass so that I can rebase my uri branch on top of this? I would like to get that in a reviewable shape. :)

Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo nitpicks

@MangoIV
Copy link
Contributor Author

MangoIV commented Aug 4, 2025

@fendor I think I applied all of your suggestions

@fendor fendor added the merge me Label to trigger pull request merge label Aug 4, 2025
@MangoIV
Copy link
Contributor Author

MangoIV commented Aug 4, 2025

Ah shoot forgot to adjust the wrapper here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants