Repository navigation
Conversation
markhpc
force-pushed
the
wip-buffered_io-merry-go-round
branch
from
March 23, 2021 20:37
fc24778 to
08fb0a4
Compare
aclamk
approved these changes
Mar 24, 2021
ifed01
reviewed
Mar 24, 2021
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
added 3 commits
March 25, 2021 14:11
Signed-off-by: Mark Nelson <[email protected]>
Signed-off-by: Mark Nelson <[email protected]>
Signed-off-by: Mark Nelson <[email protected]>
markhpc
force-pushed
the
wip-buffered_io-merry-go-round
branch
from
March 25, 2021 14:13
08fb0a4 to
fd4b8c6
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the first part in (hopefully) a series to try to improve bluefs omap performance, especially based on the multiple user issues that have been reported in various bugs, issues, and PRs (see especially #38044) with the bluefs_buffered_io=false change.
In #39976 a new benchmark was introduced to try and better understand how OMAP performs in different situations. A number of tests were performed with 100K objects each with 100 omap entries for 10M total entries. 100 unique hobject_t hashes were used to simulate the effect of spreading those objects across 100 PGs. Each omap entry has a 64byte key and 256byte value which roughly aligns with values pulled from rocksdb sst files from an RBD volume (though especially with RGW these values could be highly variable). The aggregate dataset size (~3GB) was chosen specifically to not quite fully fit inside the rocksdb block cache once populated at the default 4GB osd_memory_target but easily will fit with a larger memory target (16GB). Debug 5 was used to confirm that the priority cache memory autotuning gave rocksdb as much memory as it could to cache OMAP data (about 2.6-2.8GB in the 4GB target tests). cgroups were used to limit the process memory to 4GB or 16GB for each respective test which appears to also be setting a quota for page cache usage (Need to verify?).
The following tables showcase some of the most interesting behaviors observed:
omap_setkeys:
Data Structure
omap_get:
Data Structure
seek_to_first iteration:
Data Structure
lower_bound iteration:
Data Structure
remove
Data Structure
Some conclusions that appear to be reasonable to draw from these tests:
Bluestore appears to be much faster than filestore for omap_setkeys. In bluestore, the onode_map is implemented with an unordered_map that is vulnerable to slow performance when there are collisions hash function. With the way we populate the hobject_t hash, this manifests when the pg count is low. These tests try to simulate a pg count of 100, but in reality a lower pg count could result in a worse performance discrepancy than shown here (In cases with many collisions the effect can be significant). There are two options for improving this: (a) Simply use a data structure like std::map, btree, flatmap, etc that isn't impacted by hash collisions. (b) provide a custom std::hash specialization for the onode_map that has fewer collisions. This PR currently switches the data structure to std::map based on the belief that the onode_map will not grow excessively large due to sharding (@aclamk) and remain fast, but it's possible that with a better hash specialization for ghobject_t, unordered_map would be faster yet.
omap_get performs significantly faster when using buffered IO than direct IO. This seems to be the case even when there is enough memory available for rocksdb to cache all blocks. The primary benefit for the buffered IO tests appears to be the availability of additional page cache rather than increased block cache. This is likely the reason that filestore is faster when memory limited (filestore uses less memory than bluestore, thus more page cache is available), but in the 16GB test bluestore is faster (both have sufficient page cache to cache all SST files). Calling omap_get on ghobject_ts in the proper order (ie using std::sort rather than sorting based on object name) improves performance in all tested cases.
Iteration performance is extremely fast when all OMAP entries fit in the block cache and significantly worse when they don't. It's possible that bluestore may do better with lots of page cache and buffered IO even if the block cache isn't big enough based on the filestore results. @aclamk and I believe we may be seeing a pathologically bad case here where blocks at the beginning of an iteration may be forced out of cache at the end of the iteration, causing repeated iterations to continually reload blocks from disk. More investigation needs to happen here, though using buffered IO provides a crutch in this case when there is sufficient page cache to allow repeated iteration to proceed quickly.
remove performance is excessively slow in all cases when objects are removed in the wrong sorting order (ie when sorting by object name rather than by std::sort). This was the primary reason that several of the test cases were not completed in these charts. The best remove performance was removing in the properly sorted order using buffered io with lots of memory for page cache (or block cache). This was around 160x faster than the same test but removing in object name order. Using direct IO even with 16GB of memory for block cache was still 4x slower than using buffered IO, so there's more evidence here that we are doing extra disk reads even with a large block cache.
Given these findings, this PR does two things:
reverts bluefs_buffered_io=false until we can at least show direct IO to be as fast as buffered IO in the new OmapBench tests from [RFC] test/objectstore/store_test: First pass at an OmapBench test #39976 (with the knowledge that users may still see the excessive page cache usage issue that was reported by the perf and scale team. Provide documentation in the configuration option stating such).
switch onode_map to std::map. This is a little controversial as if there are any unexpected situations where the onode_map can grow excessively large, this should be slower than unordered_map. This is a very straightforward way to avoid the hash collision issue however and in practice @aclamk believes we should not see the onode_map grow excessively large due to sharding. There still may be a reasonable argument that we should keep unordered_map and instead provide a custom hash specialization for ghobject_t that avoids collisions, but ultimately if onode_map stays small both may be reasonable solutions to the issue.
Additional things that should be done in the future:
Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume tox