Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Stop using ReadaheadRandomAccessFile in TableCache #4052

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sagar0
Copy link
Contributor

@sagar0 sagar0 commented Jun 25, 2018

Note:
This is still a poc and NOT ready for submission, as I haven't thought though all the cases where it might cause performance regression (too many cases to think through).

Things I might be missing so far:

  • IndexReader might need its own FilePrefetchBuffer, during compactions. ie. pass along for_compaction to NewIndexIterator in BlockBasedTable::NewIterator. Otherwise we are not doing any readahead for indexes, which would be pretty bad.
  • Compaction reads with buffered IO will pollute page-cache.
  • Is Special handling needed when use_mmap_reads=true ?

Summary:
Remove ReadaheadRandomAccessFile usage in TableCache::GetTableReader. Instead let BlockBasedTableIterator and FilePrefetchBuffer handle all the readahead logic.

Test Plan:
make check -- all tests succeed.
DBIteratorTest.ReadAhead test failed since it wasn't aware of Prefetch. It started passing once I added Prefetch to CountingFile.

@sagar0 sagar0 changed the title [PocC] Remove ReadaheadRandomAccessFile usage in TableCache [PoC] Remove ReadaheadRandomAccessFile usage in TableCache Jun 25, 2018
@sagar0 sagar0 changed the title [PoC] Remove ReadaheadRandomAccessFile usage in TableCache [PoC] Stop using ReadaheadRandomAccessFile in TableCache Jun 25, 2018
@facebook-github-bot
Copy link
Contributor

Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours has expired.

Before we can review or merge your code, we need you to email cla@fb.com with your details so we can update your status.

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@sagar0 sagar0 changed the title [PoC] Stop using ReadaheadRandomAccessFile in TableCache [WIP] Stop using ReadaheadRandomAccessFile in TableCache Aug 16, 2018
facebook-github-bot pushed a commit that referenced this pull request Apr 27, 2019
Summary:
Improve the iterators performance when the user explicitly sets the readahead size via `ReadOptions.readahead_size`.

1. Stop creating new table readers when the user explicitly sets readahead size.
2. Make use of an internal buffer based on `FilePrefetchBuffer` instead of using `ReadaheadRandomAccessFileReader`, to handle the user readahead requests (for both buffered and direct io cases).
3. Add `readahead_size` to db_bench.

**Benchmarks:**
https://gist.github.com/sagar0/53693edc320a18abeaeca94ca32f5737

For 1 MB readahead, Buffered IO performance improves by 28% and Direct IO performance improves by 50%.
For 512KB readahead, Buffered IO performance improves by 30% and Direct IO performance improves by 67%.

**Test Plan:**
Updated `DBIteratorTest.ReadAhead` test to make sure that:
- no new table readers are created for iterators on setting ReadOptions.readahead_size
- At least "readahead" number of bytes are actually getting read on each iterator read.

TODO later:
- Use similar logic for compactions as well.
- This ties in nicely with #4052 and paves the way for removing ReadaheadRandomAcessFile later.
Pull Request resolved: #5246

Differential Revision: D15107946

Pulled By: sagar0

fbshipit-source-id: 2c1149729ca7d779e4e8b7710ba6f4e8cbfd3bea
vagogte pushed a commit to vagogte/rocksdb that referenced this pull request Jun 18, 2019
Summary:
Improve the iterators performance when the user explicitly sets the readahead size via `ReadOptions.readahead_size`.

1. Stop creating new table readers when the user explicitly sets readahead size.
2. Make use of an internal buffer based on `FilePrefetchBuffer` instead of using `ReadaheadRandomAccessFileReader`, to handle the user readahead requests (for both buffered and direct io cases).
3. Add `readahead_size` to db_bench.

**Benchmarks:**
https://gist.github.com/sagar0/53693edc320a18abeaeca94ca32f5737

For 1 MB readahead, Buffered IO performance improves by 28% and Direct IO performance improves by 50%.
For 512KB readahead, Buffered IO performance improves by 30% and Direct IO performance improves by 67%.

**Test Plan:**
Updated `DBIteratorTest.ReadAhead` test to make sure that:
- no new table readers are created for iterators on setting ReadOptions.readahead_size
- At least "readahead" number of bytes are actually getting read on each iterator read.

TODO later:
- Use similar logic for compactions as well.
- This ties in nicely with facebook#4052 and paves the way for removing ReadaheadRandomAcessFile later.
Pull Request resolved: facebook#5246

Differential Revision: D15107946

Pulled By: sagar0

fbshipit-source-id: 2c1149729ca7d779e4e8b7710ba6f4e8cbfd3bea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants