-
Notifications
You must be signed in to change notification settings - Fork 100
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
Optimized/Rebuild LevelDB
Native for LevelDBStore
#899
Conversation
@cschuchardt88 @Jim8y @vncoelho @superboyiii @chenzhitong @AnnaShaleva |
LevelDB
Native for LevelDBStore
LevelDB
Native for LevelDBStore
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.
@cschuchardt88 ,I would like to see a benchmark on this.
This is not the first time this part is being refactoring by you, right? Or is this continuation of previous commit?
@vncoelho This is refactoring everything. Im sure there is performance benefits. But that isn't the point of this PR. This PR fixes Examplevar options = new Options { CreateIfMissing = true };
using (var db = new DB(options, path))
{
db.Put("NA", "Na");
using(var batch = new WriteBatch())
{
batch.Delete("NA")
.Put("Tampa", "Green")
.Put("London", "red")
.Put("New York", "blue");
db.Write(batch);
}
} |
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.
Reviewed 17/36
src/LevelDBStore/LevelDBHandle.cs
Outdated
if (disposing) | ||
{ | ||
FreeManagedObjects(); | ||
} | ||
if (this.Handle != IntPtr.Zero) | ||
{ | ||
FreeUnManagedObjects(); | ||
this.Handle = IntPtr.Zero; | ||
} | ||
_disposed = true; |
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.
Move _disposed
to beginning?
if (disposing) | |
{ | |
FreeManagedObjects(); | |
} | |
if (this.Handle != IntPtr.Zero) | |
{ | |
FreeUnManagedObjects(); | |
this.Handle = IntPtr.Zero; | |
} | |
_disposed = true; | |
_disposed = true; | |
if (disposing) | |
{ | |
FreeManagedObjects(); | |
} | |
if (this.Handle != IntPtr.Zero) | |
{ | |
FreeUnManagedObjects(); | |
this.Handle = IntPtr.Zero; | |
} |
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.
_disposed
is saying have already disposed
objects. So happens after
it completes.
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.
Prevents double dispose in multiple threads.
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.
Moving above all that doesn't do anything either way. Only difference would be you set the _disposed
variable early.
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.
@cschuchardt88 You never use this.
and the code have a lot of this.
. Is this code yours?
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.
@shargon to answer your question I was keeping consistent with existing code in that library.
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.
This PR contains a massive set of changes, it's hard to review and some mistake may be done occasionally. There should be a way to split this PR into multiple granular PRs, each PR for its own optimisation. It also would be nice to distinguish optimisations and code refactoring.
Also, every optimisation should be confirmed by benchmarks, otherwise it's controversial. I'm sure there is a way of C# code profiling. Take a look at nspcc-dev/neo-go@cd42b8b, nspcc-dev/neo-go@9712be7, nspcc-dev/neo-go@ffeb3b8 and other optimisation-related PRs in NeoGo.
There shouldn't be TODOs in the resulting code, since every TODO is an issue.
Also, have you tested the resulting code against the current mainnet/testnet? Is the state compatible?
248f03a
to
c5dae4f
Compare
Yes This adds the full features of the leveldb library. |
Repository moved to neo, please re-open there |
Change Log
LevelDBStore