You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m interested in understanding the performance gained by this. I imagine it would be substantial. That is, I suspect the primary benefit to be had from this improvement is the performance gain more than the memory saving.
Using structs also improves memory locality, which increases the likelihood of CPU cache hits. Although, I suspect the standard .NET dictionary class is pretty heap allocation heavy anyway. But still, one level of indirection is better than two.
A .NET Swisstable implementation would be much better, if it existed.
I assume the entity key is used as the key in a dictionary, which is passed by value, meaning there could be a overhead in passing the struct parameter.
That being said, a lot of work has gone into RyuJIT lately to “keep structs in registers” (there is a user story by that name in the .NET runtime repo), so it’s possible that will mitigate the overhead.
If EntityKey.Equals is inlined and EntityKey.GetHashCode is devirtualised and inlined, then no problem.
In the end, it comes down to benchmarking the different design options - e.g. using BenchmarkDotNet.
Uh oh!
There was an error while loading. Please reload this page.
As shown in #1972 (comment) it gives about 6 megabytes improvement (down to 167Mb overall).
The text was updated successfully, but these errors were encountered: