-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Fixes/Optimizations/Styles
] KeyBuilder, StorageKey, StorageItem, MemorySnapshot, MemoryStore, ByteArrayComparer & ByteArrayEqualityComparer
#3705
base: master
Are you sure you want to change the base?
Conversation
Fixes/Optimizations/Styles
] KeyBuilder, StorageKey, StorageItem, MemorySnapshot, MemoryStore, ByteArrayComparer & ByteArrayEqualityComparer
@cschuchardt88 Missing |
fixed now. |
@cschuchardt88 UT isn't passed. |
OK fixed. Typo with merge. |
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.
Tested full data on mainnet, it's compatible.
Avoid remove cloone
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.
Please avoid remove the clones, this change must come alone, it could affect the security
Could you be more specific what you mean by |
?[..] and .ToArray()[..] |
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.
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.
My unique concern now is this https://github.com/neo-project/neo/pull/3705/files#r1944601500
} | ||
return cache; | ||
return _cache.ToArray(); // allocate new buffer |
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.
Every time that is invoked a new buffer is created, so the "cache" is not complete, and slower
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.
How is it slower? No memory is moved. Its like creating a Span
on byte[]
nothing moves.
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.
So my way is faster
NEW
Method | Mean | Error | StdDev | Median | Min | Max |
---|---|---|---|---|---|---|
TestDataCacheAdd | 0.0042 ns | 0.0087 ns | 0.0081 ns | 0.0000 ns | 0.0000 ns | 0.0283 ns |
TestDataCacheUpdate | 0.0062 ns | 0.0080 ns | 0.0075 ns | 0.0016 ns | 0.0000 ns | 0.0217 ns |
TestDataCacheDelete | 36.0960 ns | 0.2631 ns | 0.2461 ns | 36.1001 ns | 35.6243 ns | 36.5847 ns |
TestDataCacheGet | 0.0000 ns | 0.0000 ns | 0.0000 ns | 0.0000 ns | 0.0000 ns | 0.0000 ns |
OLD
Method | Mean | Error | StdDev | Median | Min | Max |
---|---|---|---|---|---|---|
TestDataCacheAdd | 0.0105 ns | 0.0162 ns | 0.0152 ns | 0.0062 ns | 0.0000 ns | 0.0533 ns |
TestDataCacheUpdate | 0.0011 ns | 0.0044 ns | 0.0041 ns | 0.0000 ns | 0.0000 ns | 0.0159 ns |
TestDataCacheDelete | 36.5685 ns | 0.5138 ns | 0.4807 ns | 36.4161 ns | 35.9531 ns | 37.9400 ns |
TestDataCacheGet | 0.0099 ns | 0.0187 ns | 0.0175 ns | 0.0009 ns | 0.0000 ns | 0.0582 ns |
3c567fd
to
f6b0c11
Compare
@shargon I even had @superboyiii already test before all your changes and check the data. Everything is good. After this we can remove @nan01ab I reverted back to what i had, You can review now. |
It can works, but also can be slower, and unnecessary |
So my way is faster NEW
OLD
|
Try with my changes |
Too late I forced push. Plus the only different that you ending up doing in the end, was having everything the same as before. Only change was |
NEW
OLD
Change Log
KeyBuilder
ToArray
disposing memory. Leads to not being able to callToArray
again.StorageKey
byte[]
to useMemory<byte>
for faster caching.StorageItem
ReadOnlyMemory<byte>
.byte[]
around to new instances of the class.MemorySnapshot
byte[]
seek
method to be inline withMemoryStore
,LevelDbStore
andRocksDbStore
; to allow the same results.MemoryStore
byte[]
ByteArrayComparer
IComparer
interface. To allow objects to be passed. (NOTE: Can be used with otherdotnet
classes that ONLY requireIComparer
.)ByteArrayEqualityComparer
IEqualityComparer
interface. To allow objects to be passed. (NOTE: Can be used with otherdotnet
classes that ONLY requireIEqualityComparer
.)DisallowNull
attribute onGetHashCode
parameters.Default
instance toInstance
, to matchdotnet
naming conventions.Type of change
How Has This Been Tested?
Checklist:
@superboyiii
Please test when you can.