-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Perf issues opening thousands of documents #35996
Comments
@Saurabh-Sharma what kind of project (language, size) is this? Since you mention that this cannot be reproduced without extensions, can you please help us to narrow down which extension is causing this: uninstall an extension, restart, observe whether problem persists. I understand that this painful since you have many extension installed. I would start with the extension that provides language services. |
@egamma I am using React over my project. On removing the extension, vscode worked fine. Although the same is working fine with the version prior to VSCode Version: Code 1.17.0 (be377c0, 2017-10-04T23:33:45.303Z) |
@Saurabh-Sharma thanks for following up. The fact that you say the extension wasn't a performance issue before 1.17 is a valuable hint that would help us to track the root cause of this issue. update we believe that this is caused that in 1.17 the
If the workspace is not sharable can you do a CPU profile when the extension is installed. These are the Hit F1 > Toggle Developer Tools. In the overflow menu (see below) select 'More Tools > JavaScript Profiler'. In there select start, let it profile for 30 to 60 seconds, stop it, save it to a file and attach the file here. Since the problem happens on start-up reload the window after you started the profiler using F1>Reload Window. |
The extension that triggers the CPU load is using: vscode.workspace.findFiles(`**/*.{${languages}}`, '')` in 1.17 we have switched to use ripgrep. This has changed the defaults that are excluded from The proposed fix is:
|
The PR for the extension has been submitted zignd/HTML-CSS-Class-Completion#89 |
To reproduce the issue in VS Code.
Now do the same steps in VS Code 1.17. The Problems View will contain many errors, which shows that workspace.findFiles also returns files inside the node_modules folder. These files are then opened by the extension which triggers the linters, which then report errors against the files in node_modules. |
@Saurabh-Sharma The CSS Intellisense extension just published a new version with the suggested fix. Could you check if you still see the problem with that newer version? |
@chrmarti hmm, below is a screen shot from my setup and it shows that node_modules was excluded. My screenshot is from 1.16 and yours is from 1.16.1. So this means that 1.15 did exclude node_modules. |
@egamma Did the extension auto-update in your install? Your change is already published in a new version. Do you have @jrieken When I open one of my large workspaces the 'Intellisense for CSS class names' extension quickly gets both 1.16 and 1.17 locked up. Spending a lot of time comparing URIs in: https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/api/electron-browser/mainThreadDocumentsAndEditors.ts#L107 Still looking for the regression. |
I'd say that's the effect of opening many, many documents. On every change we need to sync the documents and editor over. @chrmarti Do you have a real CPU profile that you can share? |
@jrieken I do and I think you're right. I wonder if computing the diff with a set/map instead of sorted arrays would be faster. I've copied the profiles I currently have to //mt1/eng/35996, the one I'm currently looking at is the @sandy081 Another hot spot in the profile is I don't think we can explain the reported regression yet. 1.16 performs just as badly with that many opened documents as 1.17. |
@diminutivesloop That looks like a different problem, could you open an new issue (Help > Report Issues)? Thanks. |
@sandy081 The document sorting is the bigger issue though. |
@jrieken tried with your steps and those My trace: Looking at your trace, the top consuming method seems to be this |
Yes, always reproduces. @bpasero Did you really run this on our workspace with thousands of documents (4414 to be precise)? Your longest single method runs for just a 1sec, I have runtime in the area of 10-30seconds. |
@jrieken tried on vscode workspace and I am seeing ~1700 files returned but I can try with more files. |
Yeah, seems a lot better now, mostly garbage collecting (we should memory profile this) and object-clone (/cc @sandy081 on that) |
I also noticed the cloning appearing to the top. |
Configuration is always cloned when is being asked, otherwise there could be a chance of changing the value in-memory which is error-prone. May I know where are the majority of the calls reading configuration are coming from ? I see, in most of the places, we are asking the complete configuration even though we need value for a section or for a key. Making it specific, might reduce the cloning time. |
Looks like some calls are originating from file service finding out the configured encoding for each resource that gets loaded (here). |
@sandy081 Why not call object.freeze/deepfreeze once when creating those objects? |
@jrieken I have to do deepFreeze, but did not find a native deepFreeze method. If we do deepFreeze ourselves, won't be similar to deepClone? |
We used to have
Well, you only do it once, when you compute/write the data, but not everytime you are asked for configuration (reading). |
This issue has been closed automatically because it needs more information and has not had recent activity. Please refer to our guidelines for filing issues. Thank you for your contributions. |
Configuration service was made faster by not cloning always instead of freezing once and surfacing frozen object. |
VSCode consuming high amount of CPU & memory on startup and becomes unresponsive.
I get "Window is not responding" message
Here's the CPU usage snapshot
Steps to Reproduce:
Reproduces without extensions: No
The text was updated successfully, but these errors were encountered: