Skip to content
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

use pebble nosync by default #3581

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## Pending Release

### Configs

- Added `Sync` bool option to PebbleDB configs, defaults to `false` i.e `NoSync`

## [v1.12.0](https://github.com/ava-labs/avalanchego/releases/tag/v1.12.0)

This upgrade consists of the following Avalanche Community Proposals (ACPs):
Expand Down
6 changes: 3 additions & 3 deletions database/pebbledb/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func (db *Database) NewBatch() database.Batch {

func (b *batch) Put(key, value []byte) error {
b.size += len(key) + len(value) + pebbleByteOverHead
return b.batch.Set(key, value, pebble.Sync)
return b.batch.Set(key, value, b.db.writeOptions)
}

func (b *batch) Delete(key []byte) error {
b.size += len(key) + pebbleByteOverHead
return b.batch.Delete(key, pebble.Sync)
return b.batch.Delete(key, b.db.writeOptions)
}

func (b *batch) Size() int {
Expand Down Expand Up @@ -67,7 +67,7 @@ func (b *batch) Write() error {
}

b.written = true
return updateError(b.batch.Commit(pebble.Sync))
return updateError(b.batch.Commit(b.db.writeOptions))
}

func (b *batch) Reset() {
Expand Down
8 changes: 6 additions & 2 deletions database/pebbledb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var (
MemTableSize: defaultCacheSize / 4,
MaxOpenFiles: 4096,
MaxConcurrentCompactions: 1,
Sync: false,
}
)

Expand All @@ -51,6 +52,7 @@ type Database struct {
pebbleDB *pebble.DB
closed bool
openIterators set.Set[*iter]
writeOptions *pebble.WriteOptions
}

type Config struct {
Expand All @@ -61,6 +63,7 @@ type Config struct {
MemTableSize uint64 `json:"memTableSize"`
MaxOpenFiles int `json:"maxOpenFiles"`
MaxConcurrentCompactions int `json:"maxConcurrentCompactions"`
Sync bool `json:"sync"`
}

// TODO: Add metrics
Expand Down Expand Up @@ -93,6 +96,7 @@ func New(file string, configBytes []byte, log logging.Logger, _ prometheus.Regis
return &Database{
pebbleDB: db,
openIterators: set.Set[*iter]{},
writeOptions: &pebble.WriteOptions{Sync: cfg.Sync},
}, err
}

Expand Down Expand Up @@ -167,7 +171,7 @@ func (db *Database) Put(key []byte, value []byte) error {
return database.ErrClosed
}

return updateError(db.pebbleDB.Set(key, value, pebble.Sync))
return updateError(db.pebbleDB.Set(key, value, db.writeOptions))
}

func (db *Database) Delete(key []byte) error {
Expand All @@ -178,7 +182,7 @@ func (db *Database) Delete(key []byte) error {
return database.ErrClosed
}

return updateError(db.pebbleDB.Delete(key, pebble.Sync))
return updateError(db.pebbleDB.Delete(key, db.writeOptions))
}

func (db *Database) Compact(start []byte, end []byte) error {
Expand Down
Loading