dotnet / dotnet/msbuild

Update and Remove should optimize on identity matches

Open
#2,314 2 comments 0 reactions 0 assignees View on GitHub
Area: Performance backlog triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

`Update` item operations provide a way to select items and set metadata on them.

When another item is used as selection (e.g. ``), MSBuild compares all items from the operation item type (Foo) with all items from the referenced item type (Bar) and updates the intersection. This results in N^2 runtime.

However, when the operation item type is the same as the referenced item type (e.g. ``) MSBuild could optimize and iterate over the items only once.

Suggested by @dsplaisted who found this is slow when there are many items in a self referencing update: https://github.com/Microsoft/msbuild/issues/2238#issuecomment-315937074

Optimizations:
- [x] self referencing Updates can short circuit matching altogether
- [x] extend the optimization in Update to all item operations that use matching (for now only Remove)
- [ ] add a lookup dictionary to ItemExpressionFragment such that operations that need to do matching hit the lookup instead of looping through all the ItemExpressionFragment items

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.