diff options
Diffstat (limited to 'tx.go')
-rw-r--r-- | tx.go | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -473,6 +473,8 @@ func (tx *Tx) write() error { for _, p := range tx.pages { pages = append(pages, p) } + // Clear out page cache early. + tx.pages = make(map[pgid]*page) sort.Sort(pages) // Write pages to disk in order. @@ -517,8 +519,18 @@ func (tx *Tx) write() error { } } - // Clear out page cache. - tx.pages = make(map[pgid]*page) + // put small pages back to sync.Pool + for _, p := range pages { + if int(p.overflow) != 0 || tx.db.pageSize != defaultPageSize { + continue + } + buf := (*[maxAllocSize]byte)(unsafe.Pointer(p))[:defaultPageSize] + // See https://go.googlesource.com/go/+/f03c9202c43e0abb130669852082117ca50aa9b1 + for i := range buf { + buf[i] = 0 + } + pagePool.Put(buf) + } return nil } |