mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-28 14:47:16 +00:00
e3: wal preallocate historyKey (#713)
This commit is contained in:
parent
088279e588
commit
f6029ecbe9
@ -382,7 +382,12 @@ func (d *Decompressor) WithReadAhead(f func() error) error {
|
||||
}
|
||||
|
||||
// DisableReadAhead - usage: `defer d.EnableReadAhead().DisableReadAhead()`. Please don't use this funcs without `defer` to avoid leak.
|
||||
func (d *Decompressor) DisableReadAhead() { _ = mmap.MadviseRandom(d.mmapHandle1) }
|
||||
func (d *Decompressor) DisableReadAhead() {
|
||||
if d == nil || d.mmapHandle1 == nil {
|
||||
return
|
||||
}
|
||||
_ = mmap.MadviseRandom(d.mmapHandle1)
|
||||
}
|
||||
func (d *Decompressor) EnableReadAhead() *Decompressor {
|
||||
_ = mmap.MadviseSequential(d.mmapHandle1)
|
||||
return d
|
||||
|
@ -315,7 +315,12 @@ func (idx *Index) RewriteWithOffsets(w *bufio.Writer, m map[uint64]uint64) error
|
||||
}
|
||||
|
||||
// DisableReadAhead - usage: `defer d.EnableReadAhead().DisableReadAhead()`. Please don't use this funcs without `defer` to avoid leak.
|
||||
func (idx *Index) DisableReadAhead() { _ = mmap.MadviseRandom(idx.mmapHandle1) }
|
||||
func (idx *Index) DisableReadAhead() {
|
||||
if idx == nil || idx.mmapHandle1 == nil {
|
||||
return
|
||||
}
|
||||
_ = mmap.MadviseRandom(idx.mmapHandle1)
|
||||
}
|
||||
func (idx *Index) EnableReadAhead() *Index {
|
||||
_ = mmap.MadviseSequential(idx.mmapHandle1)
|
||||
return idx
|
||||
|
@ -489,6 +489,7 @@ type historyWAL struct {
|
||||
historyVals *etl.Collector
|
||||
tmpdir string
|
||||
autoIncrementBuf []byte
|
||||
historyKey []byte
|
||||
autoIncrement uint64
|
||||
buffered bool
|
||||
}
|
||||
@ -504,6 +505,7 @@ func (h *History) newWriter(tmpdir string) *historyWAL {
|
||||
w := &historyWAL{h: h,
|
||||
tmpdir: tmpdir,
|
||||
autoIncrementBuf: make([]byte, 8),
|
||||
historyKey: make([]byte, 0, 128),
|
||||
|
||||
buffered: true,
|
||||
historyVals: etl.NewCollector(h.historyValsTable, tmpdir, etl.NewSortableBuffer(etl.BufferOptimalSize/16)),
|
||||
@ -564,7 +566,7 @@ func (h *historyWAL) addPrevValue(key1, key2, original []byte) error {
|
||||
*/
|
||||
|
||||
lk := len(key1) + len(key2)
|
||||
historyKey := make([]byte, lk+8)
|
||||
historyKey := h.historyKey[:lk+8]
|
||||
copy(historyKey, key1)
|
||||
if len(key2) > 0 {
|
||||
copy(historyKey[len(key1):], key2)
|
||||
@ -585,6 +587,8 @@ func (h *historyWAL) addPrevValue(key1, key2, original []byte) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binary.BigEndian.PutUint64(historyKey[lk:], 0)
|
||||
}
|
||||
|
||||
if err := h.h.InvertedIndex.add(historyKey, historyKey[:lk]); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user