-
Notifications
You must be signed in to change notification settings - Fork 385
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
feat: add Pebble DB backend #1069
Conversation
LGTM, could you rebase master and go mod tidy, please? Edit: did it myself, now just looking for a second review. |
This reverts commit c007c2c.
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
if err != nil { | ||
if errors.Is(err, pebble.ErrNotFound) { | ||
return nil | ||
} | ||
panic(err) | ||
} |
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.
Avoid unnecessary nesting:
if err != nil { | |
if errors.Is(err, pebble.ErrNotFound) { | |
return nil | |
} | |
panic(err) | |
} | |
if errors.Is(err, pebble.ErrNotFound) { | |
return nil | |
} | |
if err != nil { | |
panic(err) | |
} |
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 think for most of the cases where err has nil value, the suggested logic will cost more as it goes through both L57 and L60. I honestly don't see why the suggestion is a better way.
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 honestly don't see why the suggestion is a better way.
It is easier to read. If the code path is so hot that an extra if
check will affect performance meaningfully, should we add some benchmarks to be careful about that?
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.
Certainly, prioritizing readability and simplicity is beneficial, even in smaller cases. By consistently emphasizing clarity, we foster good habits and ensure our work remains accessible to others. It's a commendable practice to always strike a balance between efficiency and readability.
See #1111
if err != nil { | ||
if errors.Is(err, pebble.ErrNotFound) { | ||
return false | ||
} | ||
panic(err) | ||
} |
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.
Same as previous comment here
tm2/pkg/db/pebble_db.go
Outdated
|
||
// Implements Batch. | ||
func (ba *pebbleDBBatch) Set(key, value []byte) { | ||
ba.batch.Set(nonNilBytes(key), nonNilBytes(value), nil) |
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.
unhandled error.
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've added an error check on this.
tm2/pkg/db/pebble_db.go
Outdated
|
||
// Implements Batch. | ||
func (ba *pebbleDBBatch) Delete(key []byte) { | ||
ba.batch.Delete(nonNilBytes(key), nil) |
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.
unhandled error.
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.
also addressed
@moul just so you know, I see you updated the go.mod file and now it builds against the latest of the pebbled's master branch. Did you intend to do so? Previously I pinned the version to use the |
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the descriptionBenchmark output, based on the random read/write test patterns we have, shows faster op time compared to the default LevelDB backend. Note that this is Async read/write)