-
Notifications
You must be signed in to change notification settings - Fork 0
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
Slow Performance and Huge Memory Usage! #44
Comments
@BanjoCam, hello! I'll check, but that could be related not with the plugin, but with Sublime Text. Can you provide what version of the Sublime Text do you use? Also, please, paste your Sublime Text settings. |
Thanks for the reply! I am running the Dev build version 4102. My sublime settings:
(I have nothing set for LSP or LSP-Svelte settings) When I opened Sublime to get you these settings, it still had my Svelte project open. Here is a picture of my task manager (the RAM value was still climbing, and after 2 minutes, it still had not highlighted an intention error I put in my Svelte code): Closing that project and opening a python one: Thanks! |
Does your project have |
Just checked - I don't have one. |
Please post the full log from the server (both for ST and VSCode). |
Sublime (note that the log is still growing but it's mainly just repeating the same things). I removed my name/the project name from the logs.
VSCode:
|
How do you get it to discover all those files? For me, it starts with 0 files in all categories and doesn't increase. I've created a simple project with https://github.com/sveltejs/template. My suspicion is that this is related to file watching which LSP/ST doesn't support so it's falling back to an internal one. But it's just a wild guess at this point. |
Honestly, I have no idea. I am using largely on a fresh install of ST/Vscode and did not additional configuration - this is what the plugins are doing on my existing projects. I actually did try on a simple default svelte project. It works more as expected (ie - is usable and the RAM is not out of control.) It always starts finding 0 packages but a bit later will update with more. In this case it said zero, but after I ran the "format file" command, it spits out a new log with more file statistics.
|
Hi again, So I went into the SnapshotManager.js file found in both the Sublime and VSCode plugins. I added a "output list of files" function to the logger so I could compare what is getting included in the watcher scan. Sublime seems to be including EVERYTHING in node_modules. VSCode seems to (just eyeballing it) be limiting to files in the src folder, @types folder, and then ONLY including node_modules folders with the word "svelte" in them. I'd imagine this filter would be the main reason why the sublime file list is out of control. I have been trying to find in the vscode plugin where this filter would actually be defined, with no luck. But I would imagine that is the difference maker here. |
The client only tells the server which root folders (typically just one) are in the project (through the initialize message) and then notifying about each file that is opened. It doesn't really send any paths or filters besides that, as far as I can think of. |
You can enable server communication logs on both ST and vscode and compare what is being sent. |
Perhaps it’s some server setting that is different? |
I believe this one is different
https://github.com/sveltejs/language-tools/blob/master/packages/svelte-vscode/src/extension.ts#L102 Also I will only take a look on the weekends |
Thanks for all the help.
I figured out how to do this in VSCode (pasted below) but I don't see how to do it in ST? Also, I added the following lines to SnapshotManager.js (set function, line ~60) in the svelte-language-server node_modules folder, just to expierment:
That little tweak alone keeps the RAM usage under 1GB and makes the plugin quasi-usable... seems like kind of a crummy hack? VSCode server log:
|
Your log from vscode is not very complete. It's missing all the message exchange. Seeing the request and response for the In ST4 you enable logging with
|
It could be that. See sveltejs/language-tools#841 . It creates a file watcher without excluding In VSCode it creates a watcher using VSCode's API (here https://github.com/sveltejs/language-tools/blob/de1699fd0aa6e95dded33ad9ac7a8e4c25ea9083/packages/svelte-vscode/src/extension.ts#L92) which I think ignores changes to If that's that then a way to reproduce could be to cc @jasonlyu123 |
The log I included there was only when I changed the settings to "verbose" in vscode but I did include a log earlier #44 (comment) that had the initialize code for ST and VScode. Does that look right? I am playing around on my Mac at home, I had cloned my repo and actually forgot to do an npm install when I was testing yesterday. It loaded 85 files before I did the install and was working great. After the install it simply crashed and showed this in the log:
On vscode:
So, exactly the same issues (file counts are a bit different likely because this is a different project, but very similar in structure.) |
I also suspect it's related to file watching. We just have a PR sveltejs/language-tools#950 to exclude node_modules from the fallback watcher. From his investigation, there are likely other language services initialized to target a module in the node_module folder. Maybe that would help. |
The codebases I'm currently working on are not super shareable. If I get some time tomorrow I'll try to make a dummy codebase that can re-create the issue and could be used for testing. FYI I just did the same experiment (git clone repo, npm install, then open Sublime and point to it) on my beefier linux box, and am getting the same issues (7000+ files scanned, about 2.5GB ram used). Thanks again! |
@BanjoCam if that suspicion is correct then disabling the following code should result in the problem going away |
Wow! I don't know how to recompile the server, but I went into the compiled plugin directory and opened the compiled server.js file. I found what appeared to be the compiled version of this ts code (lines 57-61)
and commented it out. Restarted sublime - node is sitting around 239mb ram now, the plugin is performant similar to the VSCode one. After the initial "files: 0" that always appears in the LSP logs, I now see
which again is very similar to VSCode. It stops updating after this and doesn't grow into the thousands as before. THANK YOU! EDIT: tried the same fix on my mac and also worked 👍 |
@BanjoCam, I've just pushed |
Yes - it works, and it's glorious! |
Hi there,
Thank you so much for making this plugin. I have installed the latest version. On Windows 10.
When I use the VSCode version of the plugin, it loads to about 500MB ram, and works great. When I load the exact same project in Sublime, the Node instance goes up to about 3 GB of ram. It takes a long time to get to this point and the plugin more or less doesn't work until then (and is variably unresponsive afterwards). I checked the output logs in both software and I think it may have something to do with how the plugin is indexing files. In VSCode:
SnapshotManager File Statistics:
Project files: 0
Svelte files: 20
From node_modules: 944
Total: 964
The same project in Svelte (and this may still be climbing, I got impatient)
LSP-svelte: SnapshotManager File Statistics:
LSP-svelte: Project files: 0
LSP-svelte: Svelte files: 21
LSP-svelte: From node_modules: 7869
LSP-svelte: Total: 7892
I feel like there must be some sort of file exclusion filter turned off or something. I also don't know what counts as a "Svelte file" but all of the .svelte and .js files in my SRC folder count up to 20. 21 is only if a CSS file is included. I tried copying over the VScode version of the various node_modules folder in the plugin. I also tried copying over the LSP svelte settings from VScode. Nothing made a difference and I don't think I'm smart enough to go further than that!
Thanks for any help you can provide!
The text was updated successfully, but these errors were encountered: