facebook / facebook/rocksdb

save unnecessary allocations in mmap mode

Open
#8,422 1 comment 0 reactions 0 assignees View on GitHub
enhancement up-for-grabs
Dominant language
C++
Stars
32.1k
Forks
6.9k
Avg merge
32m
Merged PRs (30d)
1

Description

Currently the RandomAccessFile::Read() API guarantees it'll be provided a scratch buffer large enough to store its result. However that buffer is not needed for `mmap()`-based file readers as those can return slices directly into mapped memory.

Perhaps we can introduce a RandomAccessFile{,Reader}::MappedRead() that does not take the scratch buffer and is tried first when allow_mmap_reads && immortal_table. If it returns NotSupported (the default implementation), we could fall back to allocating and then calling RandomAccessFileReader::Read() as before.

Edit: Note the current behavior involves a call to the allocator only for blocks bigger than kDefaultStackBufferSize (5000) bytes. Otherwise it uses a stack buffer which should not be a problem.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.