mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-01 00:31:21 +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.
|
// 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 {
|
func (d *Decompressor) EnableReadAhead() *Decompressor {
|
||||||
_ = mmap.MadviseSequential(d.mmapHandle1)
|
_ = mmap.MadviseSequential(d.mmapHandle1)
|
||||||
return d
|
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.
|
// 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 {
|
func (idx *Index) EnableReadAhead() *Index {
|
||||||
_ = mmap.MadviseSequential(idx.mmapHandle1)
|
_ = mmap.MadviseSequential(idx.mmapHandle1)
|
||||||
return idx
|
return idx
|
||||||
|
@ -489,6 +489,7 @@ type historyWAL struct {
|
|||||||
historyVals *etl.Collector
|
historyVals *etl.Collector
|
||||||
tmpdir string
|
tmpdir string
|
||||||
autoIncrementBuf []byte
|
autoIncrementBuf []byte
|
||||||
|
historyKey []byte
|
||||||
autoIncrement uint64
|
autoIncrement uint64
|
||||||
buffered bool
|
buffered bool
|
||||||
}
|
}
|
||||||
@ -504,6 +505,7 @@ func (h *History) newWriter(tmpdir string) *historyWAL {
|
|||||||
w := &historyWAL{h: h,
|
w := &historyWAL{h: h,
|
||||||
tmpdir: tmpdir,
|
tmpdir: tmpdir,
|
||||||
autoIncrementBuf: make([]byte, 8),
|
autoIncrementBuf: make([]byte, 8),
|
||||||
|
historyKey: make([]byte, 0, 128),
|
||||||
|
|
||||||
buffered: true,
|
buffered: true,
|
||||||
historyVals: etl.NewCollector(h.historyValsTable, tmpdir, etl.NewSortableBuffer(etl.BufferOptimalSize/16)),
|
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)
|
lk := len(key1) + len(key2)
|
||||||
historyKey := make([]byte, lk+8)
|
historyKey := h.historyKey[:lk+8]
|
||||||
copy(historyKey, key1)
|
copy(historyKey, key1)
|
||||||
if len(key2) > 0 {
|
if len(key2) > 0 {
|
||||||
copy(historyKey[len(key1):], key2)
|
copy(historyKey[len(key1):], key2)
|
||||||
@ -585,6 +587,8 @@ func (h *historyWAL) addPrevValue(key1, key2, original []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
binary.BigEndian.PutUint64(historyKey[lk:], 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.h.InvertedIndex.add(historyKey, historyKey[:lk]); err != nil {
|
if err := h.h.InvertedIndex.add(historyKey, historyKey[:lk]); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user