mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-09 22:51:02 +00:00
don't fsync on RBF Open if WAL is empty
This is targeted at reducing startup times, especially on OSX where the fsync calls seem to be taking an egregiously long time. I got one index to go from ~1min to open to ~1sec. This looks safe to me, but will get opinions from RBF experts.
This commit is contained in:
parent
115b1a9c6a
commit
c3e14cb9ae
1 changed files with 8 additions and 1 deletions
|
|
@ -206,6 +206,13 @@ func (db *DB) checkpoint() error {
|
|||
return nil // skip if transactions open
|
||||
}
|
||||
|
||||
// Check if there are any WAL pages, if not do nothing as
|
||||
// checkpointing and calling fsync can be very expensive even if
|
||||
// there are no writes.
|
||||
if db.walPageN == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < db.walPageN; i++ {
|
||||
page, err := db.readWALPageAt(i)
|
||||
if err != nil {
|
||||
|
|
@ -245,7 +252,7 @@ func (db *DB) checkpoint() error {
|
|||
db.walPageN = 0
|
||||
db.pageMap = NewPageMap()
|
||||
|
||||
// Notify halted tranactions that the WAL has been checkpointed.
|
||||
// Notify halted transactions that the WAL has been checkpointed.
|
||||
db.haltCond.Broadcast()
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue