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

nixd/fork: forking concurrency #50

Merged
merged 21 commits into from Jun 3, 2023
Merged

nixd/fork: forking concurrency #50

merged 21 commits into from Jun 3, 2023

Conversation

inclyc
Copy link
Member

@inclyc inclyc commented Jun 1, 2023

I'd like to eval workspace files in a separated process. When we update the workspace, we call fork() to lazily duplicate nixd itself. And, the server turns itself into Worker mode, which means:

  1. Enable language feature by calling nix::init*, and also start the GC.
  2. Do not response workspace update request, just fixing the workspace, with evaluation runs at once.
  3. Handle LSP features, like Hover
  4. The Worker itself runs in single-thread mode.

The main process it self redirects LSP requests to versioned workers, and just choose the best result, and thus should be cancellable.

The workers are managed in a deque, which means we can kill outdated processes (and thus free the memory).

regression status:

  • diagnostic
  • completion
  • hover

lib/nixd/src/ServerController.cpp Outdated Show resolved Hide resolved
lib/nixd/include/nixd/Server.h Outdated Show resolved Hide resolved
@inclyc
Copy link
Member Author

inclyc commented Jun 3, 2023

Now all features are implemented in forking architecture, however looks like something is not working in github ci, but I cannot reproduce locally.

@inclyc inclyc marked this pull request as ready for review June 3, 2023 04:23
lib/nixd/include/nixd/Server.h Outdated Show resolved Hide resolved
@inclyc inclyc merged commit 2ce0a61 into main Jun 3, 2023
28 checks passed
@inclyc inclyc deleted the nixd/fork branch June 3, 2023 08:52
@inclyc inclyc mentioned this pull request Jun 3, 2023
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants