Performance impact by searching excluded directories
See original GitHub issueSteps to reproduce
- Create a web project
- have a large folder with thousands of files in it (ie.
node_modules
) - exclude the folder in the
.csproj
file for performance reasons
<ItemGroup>
<Compile Remove="node_modules\**" />
<Content Remove="node_modules\**" />
<EmbeddedResource Remove="node_modules\**" />
<None Remove="node_modules\**" />
</ItemGroup>
Expected behavior
- the folder should be ignored by the dotnet command
- project should load really fast in Visual Studio and JetBrains Raider
Actual behavior
- the folder is searched recursively
- (issue was determined using the Sysinternals Process Monitor)
- project takes way too long to load
- creating/renaming/refactoring files and folders in Visual Studio takes way longer
- more RAM consumption
Environment data
dotnet --info
output:
.NET Command Line Tools (2.0.0)
Product Information:
Version: 2.0.0
Commit SHA-1 hash: cdcd1928c9
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.0.0\
Microsoft .NET Core Shared Framework Host
Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Performance impact by searching excluded directories #8659
Steps to reproduce Create a web project have a large folder with thousands of files in it (ie. node_modules) exclude the folder in...
Read more >What are the pros and cons of excluding folders in Defender?
The main argument for excluding folders, in particular those with many files, was performance. Although some questioned the validity of the ...
Read more >Question - Search Index - Which Folders to Exclude
I'm guessing the performance impact is only on the initial index and then the incremental doesn't really affect anything. They even pause it ......
Read more >Troubleshoot Windows Search performance
The primary factors that affect indexing performance are the number of ... To exclude whole folders from the index, select Settings > Search ......
Read more >Search in Finder while ignore it in Spotlight
Exclude Specific Folders in Finder Search without removing from Spotlight ... I think the enormous number of files will affect the indexes.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem here is that the items are added beforehand so to exclude the folder being searched is to add it to the
DefaultItemExcludes
property like the web SDK already does for ASP.NET Core project.To do it in non ASP.NET Core projects, you’d have to add a similar property redefinition to your csproj:
Note that there is a performance issue in glob expansion with patterns like
**/node_modules/**
at the moment so you’ll have to add the folders explicitly (best at the start of theDefaultItemExcludes
as shown above)Got it, thank you for the quick reply and the thorough explanation. So if I understand correctly (and my short tests seem to confirm this) if you care about performance, and you want Visual Studio and MSBuild to basically not know about certain files then the thing you want to use, and you don’t need anything else, is
DefaultItemExcludes
, right? So no need for (or any benefit to) also use e.g. the following for git file?<EmbeddedResource Remove=".git" />
and<None Remove=".git" />
. I’d use something like this:I wish it wasn’t necessary to have a PhD in MSBuild to use Node but working on my thesis now 😃.