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

Clean up of hashset #7344

Closed
wants to merge 1 commit into from
Closed

Clean up of hashset #7344

wants to merge 1 commit into from

Conversation

elachlan
Copy link
Contributor

@elachlan elachlan commented Jan 27, 2022

Initial work on #7340

First changes are about making it easier to diff between CORE and MSBuild.

Imported changes to HashHelpers from CORE.

Still working on merging changes from CORE to RetrievableEntryHashSet.

@elachlan elachlan marked this pull request as draft January 27, 2022 21:53
Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't figured out the point of the changes to HashHelpers and HashHelpers.SerializationInfoTable.cs—is there a specific bug you were trying to resolve? The changes to HashSet looked much more cleanup-oriented.

// This is the maximum prime smaller than Array.MaxArrayLength
internal const int MaxPrimeArrayLength = 0x7FEFFFFD;

public const int HashPrime = 101;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we use this other than making sure we don't pick an almost-multiple of it?

Array.Clear(_slots, 0, _lastIndex);
#if NET6_0_OR_GREATER
Array.Clear(_buckets);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I do think this is cleaner, adding the #ifs makes it very not worth it to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might have been done because of a slight codegen improvement. (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I used it was because CORE used it. When I checked the source code for it, it was a lot more simple. So it should run faster.

@elachlan
Copy link
Contributor Author

I haven't figured out the point of the changes to HashHelpers and HashHelpers.SerializationInfoTable.cs—is there a specific bug you were trying to resolve? The changes to HashSet looked much more cleanup-oriented.

The Helper changes are to get in line with CORE. They added the SerializationInfoTable back in 2020 to help with serialization.

The changes to Hashset are to reduce the effort of a diff.

{
private static ConditionalWeakTable<object, SerializationInfo>? s_serializationInfoTable;

public static ConditionalWeakTable<object, SerializationInfo> SerializationInfoTable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't review the other code at the moment but if MSBuild uses BinarySerializer it will need to stop doing so per the published deprecation plan. If it does not then this code should be dead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've mostly moved off of it. GenerateResource might need to continue to support it even after the runtime doesn't because it's one of the options we provide. We also haven't fully fixed BinaryTranslator.TranslateDotNet, and I agree we should get back to that when we can. Canonical issue: #6215

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SerializationInfoTable is copied from CORE. It exists in core right now afaik.

Copy link
Member

@danmoseley danmoseley Jan 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, for anyone using BinarySerializer. It's only needed here if MSBuild uses that on these objects. If not then the type does not need to implement ISerializable at all

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint FastMod(uint value, uint divisor, ulong multiplier)
{
// We use modified Daniel Lemire's fastmod algorithm (https://github.com/dotnet/runtime/pull/406),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need a third party notices entry added. You could check the original PR that added this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elachlan elachlan closed this Aug 6, 2022
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.

4 participants