-
Notifications
You must be signed in to change notification settings - Fork 27
Optimize IDisposable implementations #344
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
Optimize IDisposable implementations #344
Conversation
* Optimize IDisposable implementations * optimize new List<>(1) * Optimize EnableSystemOperationRegistration() * Fix Race condition in tests * Fix Race condition in tests * Add [MethodImpl(MethodImplOptions.NoInlining)]
@@ -11,17 +11,26 @@ namespace Xtensive.Orm | |||
{ | |||
public partial class Session | |||
{ | |||
public readonly struct SystemLogicOnlyRegionScope : IDisposable |
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 believe that we can make it internal and roll back to IDisposable
in the DirectSessionAccessor
.
Do you have any usage of DirectSessionAccessor.OpenSystemLogicOnlyRegion
method?
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.
Do you have any usage of
DirectSessionAccessor.OpenSystemLogicOnlyRegion
method?
Yes, we do
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.
Got it
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.
It is reasonable to restrict access to the scope constructor to keep creations within project
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.
roll back to
IDisposable
in theDirectSessionAccessor
.
returning IDisposable
requires heap allocation. That was the reason of this PR to avoid unnecessary allocations.
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 know, this is why I no longer require you to make type internal. I'm talking about the type constructor, there is no reason for it to be used outside project.
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.
Changed SystemLogicOnlyRegionScope()
ctor to be internal
OpenSystemLogicOnlyRegion()
,EnableSystemOperationRegistration()
,DisableSystemOperationRegistration()
alloc-less (there were 2 allocations: forDisposable<>
& closure)RegisterRoot()
EmptyDisposable
where possibleif (!hashSet.Contains(x)) hashSet.Add(x);
pattern intohashSet.Add(x)
to avoid double searchPrefetchManagerBasicTest
: prohibit JIT to inline the function