-
Notifications
You must be signed in to change notification settings - Fork 32
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
Make SymbolServer.jl more library-like #270
Conversation
What is with the disc -> disk thing? Isn't this merely British versus American spelling? |
No, I put a citation in the commit message:
https://grammarist.com/spelling/disc-disk/ This is also the case in Britain; the article provides a link to the Telegraph with an example. |
This will most likely not work, the reason for the current design is that the indexing process runs in the user environment where it does not have access to the If we wanted to rearrange things here then I think we could move the various "application like" scripts into a separate folder just to make it clearer that these are not part of the module defined by the package, but rather are code that is meant to run in a special child process. And I guess we could expose another function from the regular package that launches a child process and indexes a given package. But the core idea that the indexing should run in a separate process that does not have regular |
Oh, and just as a side note: it is much easier to separate things like spelling changes out into separate PRs. PRs are much easier to handle for us if they each do one thing only. PRs that fix a whole variety of things that are unrelated are more difficult to review, and most likely will take longer to process. |
I wouldn't normally open a whole PR just to be pedantic about spelling :P. I'm happy to split those commits off if you prefer. They would produce a merge conflict with the current changes though.
Hmm, I'll have to think about this a bit more. Why is it important that Maybe we could just move the indexing logic into separate On the general idea of launching things in separate processes: I don't love it, because due to Julia's precompilation, every additional process tends to lead to significant additional latency and memory usage. Also, the fact the |
We want to run the indexing in exactly the same environment that the user has set up. And that environment almost certainly won't have
Yes, I think that could work, but really the design of the package
The general idea here is this: we never want to load or run any user-code inside the language server process. Otherwise, the LS would crash every time there is a bug in a package that a user loads. That is not an option for us, the LS provides too many capabilities that work even if a user tries to load a package with an error to completely give up in these situations. The primary reason for the two-process model is to isolate and harden the language server process against errors in packages that users use. |
PRs with just spelling or grammar changes are much easier to merge than ones mixed in with technical changes. There should not be a merge conflict with the changes are exactly the same. |
Thanks for explaining @davidanthoff! It seems this PR isn't mergeable for now so I'll close it. I opened #271 with the spelling stuff.
Possibly naive question, but aren't there tricks to work around this? I'm no Julia expert but I came across this method for loading a package using metaprogramming. (It presumably could be combined with a try/catch block, and even |
I don't think so. Most basic situation: what if user code runs |
Hmm, a library calling However--has anyone ever thought about doing this analysis statically, without loading code at all? I was looking at JuliaSyntax.jl and it seems like a pretty impressive project, and advertises that one of its goals (besides speed) is to support tooling. Static analysis is how most LSP implementations work after all. As a point of comparison: Python is similar to Julia in many ways, as an interpreted language which has the ability to run side-effectful code at import time. All the Python LSP servers I'm aware of rely on static analysis using a library such as jedi. The now-deprecated Microsoft Python language server wasn't even written in Python. Could there be a future where Julia's language server works the same way? |
Yeah, that is probably not the best example. But for example, any binary shared library that any package loads that crashes would take down the entire language server. And when that crashes, a lot of things in the extension stop working, so that is just not an option.
Yes, at the moment we are doing a hybrid: we look at the current project, and for anything that is deved we use static analysis, and for all other packages we extract all information via the SymbolServer.jl (either from a cloud cache or by loading it locally once and then caching locally). The problem with static analysis is that Julia is a very dynamic language and we essentially stand no chance of really ever fully getting it right. Things like |
This is an effort to make
SymbolServer.jl
more library-like, in the sense that significant logic is not hidden in script files likeindexpackage.jl
andserver.jl
. This logic is now exposed in two exported functions:SymbolServer.index_package
andSymbolServer.index_packages
, to make it easier for third party packages to use.There are also some miscellaneous spelling and grammar fixes, as well as a few
@time
calls to help with profiling the indexing process. It's probably easiest to review this commit-by-commit.For every PR, please check the following: