increase IO buffers size ()

* increase IO buffers size

* found SSD threshold
This commit is contained in:
Alex Sharov 2020-06-25 14:34:40 +07:00 committed by GitHub
parent daba929bd8
commit b26b00f72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -16,6 +16,7 @@ const (
SortableOldestAppearedBuffer
BufferOptimalSize = 256 * 1024 * 1024 /* 256 mb | var because we want to sometimes change it from tests */
BufIOSize = 64 * 4096 // 64 pages | default is 1 page | increasing further doesn't show speedup on SSD
)
type Buffer interface {

View File

@ -35,12 +35,11 @@ func FlushToDisk(encoder Encoder, currentKey []byte, b Buffer, datadir string) (
if err != nil {
return nil, err
}
defer bufferFile.Sync() //nolint:errcheck
w := bufio.NewWriter(bufferFile)
w := bufio.NewWriterSize(bufferFile, BufIOSize)
defer w.Flush() //nolint:errcheck
defer func() {
bufferFile.Sync() //nolint:errcheck
}()
encoder.Reset(w)
for _, entry := range b.GetEntries() {
err = writeToDisk(encoder, entry.key, entry.value)
@ -66,7 +65,7 @@ func (p *fileDataProvider) Next(decoder Decoder) ([]byte, []byte, error) {
if err != nil {
return nil, nil, err
}
p.reader = bufio.NewReader(p.file)
p.reader = bufio.NewReaderSize(p.file, BufIOSize)
}
decoder.Reset(p.reader)
return readElementFromDisk(decoder)