Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ava-labs/avalanchego
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6e0b41cf4d2a43b14365a3318e1e1ae6b41c6098
Choose a base ref
..
head repository: ava-labs/avalanchego
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 981663df541d0069288050f37ea65db1aa257ca3
Choose a head ref
Showing with 9 additions and 5 deletions.
  1. +3 −3 database/pebbledb/batch.go
  2. +6 −2 database/pebbledb/db.go
6 changes: 3 additions & 3 deletions database/pebbledb/batch.go
Original file line number Diff line number Diff line change
@@ -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 {
@@ -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() {
8 changes: 6 additions & 2 deletions database/pebbledb/db.go
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ var (
MemTableSize: defaultCacheSize / 4,
MaxOpenFiles: 4096,
MaxConcurrentCompactions: 1,
Sync: true,
}
)

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

type Config struct {
@@ -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
@@ -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
}

@@ -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 {
@@ -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 {