-
-
Notifications
You must be signed in to change notification settings - Fork 545
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
EquivalencyValidator performance fixes #935
Conversation
Thanks for taking a look at this part of the code base and submitting a PR. Can you comment more the effects the individual changes had? What were the absolute improvements on your tests? @adamvoss As far as I could trace this back, you authored the initial implementation of this. |
The conditionals before For one class of tests the absolute improvement was from 17 to 13 seconds, but I don't have data for all our tests (this includes everything, e.g. starting up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you see from my comments, I'm really interested in what differences the different parts make.
Do you have a test case you can share?
For inspiration have a look at #817 (comment) where I extracted the relevant changes into eight separated commits, so I could run isolated benchmarks against them.
{ | ||
return (@object.GetHashCode() * 397) ^ path.GetHashCode(); | ||
} | ||
return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(@object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ I guess you saw that getting HashCode
of the old path
array, didn't make much sense.
Can you comment on why you chose RuntimeHelpers.GetHashCode
over Object.GetHashCode()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we want to compare/hash the object reference not value. RuntimeHelpers.GetHashCode
returns the object identity hash even if it overrides Object.GetHashCode
.
I'm not sure if this is even used anywhere, it looks like ObjectReference
is only used in lists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried a dig a bit in the git history to get some context:
ObjectReference
was added in 5e6d9ee4 where it had a (to me) sensibleGetHashCode
.- It was changed in 02e71b30 from
string propertyPath
tostring[] path
, butGetHashCode
was not updated. - probably due to that, perf optimization of ShouldAllBeEquivalentTo for large collections #395 did not work as
ObjectReference
s are now stored inHashSet
. - Undone a breaking change in the way the object tracker works. #399 reverted that PR.
Src/FluentAssertions/Equivalency/GenericDictionaryEquivalencyStep.cs
Outdated
Show resolved
Hide resolved
Src/FluentAssertions/Equivalency/GenericDictionaryEquivalencyStep.cs
Outdated
Show resolved
Hide resolved
Src/FluentAssertions/Equivalency/EnumerableEquivalencyValidator.cs
Outdated
Show resolved
Hide resolved
Src/FluentAssertions/Equivalency/GenericDictionaryEquivalencyStep.cs
Outdated
Show resolved
Hide resolved
Src/FluentAssertions/Equivalency/GenericDictionaryEquivalencyStep.cs
Outdated
Show resolved
Hide resolved
@pentp Please let me know if I can be of any help. If you split the PR into more isolated commits, such as e.g.
I'll try to setup some benchmarks to get some numbers. |
Hi @pentp, do you think you'll be able to follow up? |
Yes, I planned to check up on this PR this week, so hopefully tomorrow. I have some measurements saved, just need to check which changes gave only minor improvements and probably just undo those. |
cd214ab
to
976b3df
Compare
@pentp This looks very nice! |
No, this should be ready for merge. |
Needs to be rebased |
Hi, I'm Dan Voss -- Adam's dad. I found this question while wrapping up Adam's digital accounts. I regret to inform you that Adam died in July. http://schluterbalikfuneralhome.com/obituary/adam-voss |
Don't know what to say.... |
Rebased |
Hi, I'm Dan Voss -- Adam's Dad. I've only recently gotten access to his
e-mail and see that a question was posed to him in this thread. I'm sorry
to inform you that Adam died in July -- which is why you haven't had any
response.
…On Tue, Nov 20, 2018 at 4:17 AM Dennis Doomen ***@***.***> wrote:
Merged #935
<#935> into
master.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#935 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA67P4RDisugkobPPpuEuML0Ix-l0Y-_ks5uw9augaJpZM4XEIHi>
.
|
This fixes
GenericDictionaryEquivalencyStep
andGenericEnumerableEquivalencyStep
performance problems caused by the use of uncachedLambdaCompiler.Compile
which is very expensive.Related to #475.
This makes
ObjectAssertions.BeEquivalentTo
about 4.3x faster in our test projects.