Skip to content
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

Update RetrievableEntryHashSet to match changes in HashSet #9042

Closed
wants to merge 24 commits into from

Conversation

danmoseley
Copy link
Member

MSBuild has a "RetrievableEntryHashSet" which is like a Dictionary but the entries store both key and value so it can have the small size of a hashset. There are a few other semantic changes listed in the comment on the class.

Since RetrievableEntryHashSet snapped official Hashset code 15 years ago, numerous improvements have been made to Hashset for size and performance. This brings over those improvements.

I also removed the 'version' field from these -- it's a feature of many of our collections that help ensure the enumerator isn't invalidated during enumeration. We've considered removing it altogether. In the MSBuild use case here, I believe the value if any is not worth the 4 extra bytes on the object, as IIRC there end up being a lot of these objects. I synthesized a version from the other fields that is almost as good, instead.

This brings the "fastmod" optimization which in corelib is only used in 64 bit builds. MSBuild does not build separate 32 and 64 bit builds so I used this path in both bitnesses. It may be a slight deoptimization for lookups when running in a 32 bit process, hopefully outweighed by the improvement in 64 bit which is much more common.

This ought to be measured for performance -- is there a magic way to do that before/after?

@rainersigwald
Copy link
Member

This ought to be measured for performance -- is there a magic way to do that before/after?

We can trivially run the Visual Studio "Perf DDRITs", by pushing to a branch with the special name exp/*. I pushed to https://github.com/dotnet/msbuild/tree/exp/danmose-hashset, which is building as https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=8076262, which will trigger the test insertion.

@AR-May is any of your test infra ready to try this? I think it's not, quite yet.

@danmoseley
Copy link
Member Author

Nice. How do I see the results?

@danmoseley
Copy link
Member Author

danmoseley commented Jul 14, 2023

I would imagine any changes here vanish in the noise unless perhaps it's pure incremental build of a tree with no VS time in it.

When MSBuild runs in a VS build, is it 64 bit? I guess the inproc part is 32 bit

@danmoseley danmoseley changed the title Improvehashset Update RetrievableEntryHashSet to match changes in HashSet Jul 17, 2023
@AR-May
Copy link
Member

AR-May commented Jul 18, 2023

The infra is not yet ready for that indeed.

@danmoseley the results are in the VS experimental PR, I tagged you there. I indeed do not see any perf improvements, I guess due to the noise as you mentioned.

@AR-May AR-May self-requested a review July 18, 2023 13:39
@AR-May AR-May requested a review from rokonec July 18, 2023 13:39
@danmoseley
Copy link
Member Author

@AR-May thanks. I put in the internal ticket:

We can either (1) leave the code as is (2) take it because there's some value in aligning with Hashset (3) take it because we expect there may be marginal improvements, lost here in the noise. (4) make more limited changes (5) take it at the start of preview 9.
What do you suggest? I'd be inclined to do (5) I think, I can extract a few small low risk pieces for .NET 8 and leave the rest for .NET 9 (and we could choose to not do it then)

@danmoseley
Copy link
Member Author

danmoseley commented Jul 18, 2023

IIRC there end up being a lot of these objects

hmm, looking at the code as it is today, there shouldn't be a huge number of these per project. So the size is relatively uninteresting. Perf may be, but apparently it's not significant enough to show up in the perf lab.

@danmoseley
Copy link
Member Author

I'm going to close this as I don't see good reason for this much churn right now. I may offer some small PR's with pieces.

@danmoseley danmoseley closed this Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants