-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Sort per-file blob read requests by offset #8953
Sort per-file blob read requests by offset #8953
Conversation
9e0da46
to
4c37b0e
Compare
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for the fix @riversand963 !
db/version_set.cc
Outdated
blobs_in_file.begin(), blobs_in_file.end(), | ||
[](const BlobReadRequest& lhs, const BlobReadRequest& rhs) -> bool { | ||
assert(lhs.first.file_number() == rhs.first.file_number()); | ||
return lhs.first.offset() <= rhs.first.offset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably does not make any practical difference but I think it would be nice to use strictly less here
db/blob/db_blob_basic_test.cc
Outdated
SyncPoint::GetInstance()->ClearAllCallBacks(); | ||
SyncPoint::GetInstance()->SetCallBack( | ||
"RandomAccessFileReader::MultiRead:AlignedReqs", [&](void* arg) { | ||
auto* aligned_reqs = reinterpret_cast<std::vector<FSReadRequest>*>(arg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static_cast
would be sufficient here
db/blob/db_blob_basic_test.cc
Outdated
SyncPoint::GetInstance()->DisableProcessing(); | ||
SyncPoint::GetInstance()->ClearAllCallBacks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor but it would be nice to move these to right after the MultiGet
call so they are executed even in the case of assertion failures.
@@ -127,6 +127,189 @@ TEST_F(DBBlobBasicTest, MultiGetBlobs) { | |||
} | |||
} | |||
|
|||
TEST_F(DBBlobBasicTest, MultiGetWithDirectIO) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this awesome unit test @riversand963 !
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
Thanks @ltamasi for the review! |
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
c7e2ae1
to
c891af6
Compare
@riversand963 has updated the pull request. You must reimport the pull request before landing. |
@riversand963 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: `RandomAccessFileReader::MultiRead()` tries to merge requests in direct IO, assuming input IO requests are sorted by offsets. Add a test in direct IO mode. Pull Request resolved: #8953 Test Plan: make check Reviewed By: ltamasi Differential Revision: D31183546 Pulled By: riversand963 fbshipit-source-id: 5d043ec68e2daa47a3149066150afd41ee3d73e6
But you didn't add a comment on BlobFileReader::MultiGetBlob (nor MultiRead?) that they expect sorted inputs? |
@pdillinger oops, we should have added comment and checks for |
I was looking at FSRandomAccessFile::MultiRead, which still does not have such a comment. (When I approved #8972 I was not in a position to verify this claim.) |
It's |
Implementations of FSRandomAccessFile::MultiRead are provided by both RocksDB and advanced users. Evidently confusion ensues when it is not clear whether sorting is required for the caller or whether the callee must deal with unsorted requests; "ambiguity means the callee must sort it out" is evidently not good enough. (Sorry if my meta-point "sortedness requirements should be clear" was confused by suggesting we add a comment like "inputs must be sorted.")
Seems you agree it's ambiguous. |
Especially if we currently always provide sorted requests but make no promise to continue that in the future. |
No, what I meant above is that I didn't bother to check :) I did now and neither Personally, I'm perfectly fine with not having a comment for non-requirements. As a developer, I would assume that as long as I'm not told explicitly that requests have to be sorted, they don't have to be. |
A non-requirement on the caller is a requirement for the callee. Many implicit requirements (e.g. nullability) are often obvious and relatively low-risk (crash). Sortedness is tricky and high-risk (corruption). Our job is not to have a plausible claim of "someone else's problem" but to mitigate the risk of problems. :) We have a history of people depending on our implementation details (here "you always passed in a sorted list before") and things breaking when we change implementation details. |
I am trying to understand where the confusion and risk is.
Besides, |
Summary: * Clarify that RocksDB is not exception safe on many of our callback and extension interfaces * Clarify FSRandomAccessFile::MultiRead implementations must accept non-sorted inputs (see #8953) * Clarify ConcurrentTaskLimiter and SstFileManager are not (currently) extensible interfaces * Mark WriteBufferManager as `final`, so it is then clearly not a callback interface, even though it smells like one * Clarify TablePropertiesCollector Status returns are mostly ignored Pull Request resolved: #9080 Test Plan: comments only (except WriteBufferManager final) Reviewed By: ajkr Differential Revision: D31968782 Pulled By: pdillinger fbshipit-source-id: 11b648ce3ce3c5e5bdc02d2eafc7ea4b864bd1d2
Summary: `RandomAccessFileReader::MultiRead()` tries to merge requests in direct IO, assuming input IO requests are sorted by offsets. Add a test in direct IO mode. Pull Request resolved: facebook/rocksdb#8953 Test Plan: make check Reviewed By: ltamasi Differential Revision: D31183546 Pulled By: riversand963 fbshipit-source-id: 5d043ec68e2daa47a3149066150afd41ee3d73e6
RandomAccessFileReader::MultiRead()
tries to merge requests in direct IO, assuming input IO requests aresorted by offsets.
Add a test in direct IO mode.
Test plan:
make check