Skip to content

crimson/os/seastore/btree: link fixedkvbtree's nodes and logical extents with forward and backward pointers, and drop the pin_set - #47749

Merged
cyx1231st merged 21 commits into
ceph:mainfrom
xxhdx1985126:wip-intra-fixedkvbtree-pointers-2
May 9, 2023

Conversation

@xxhdx1985126

@xxhdx1985126 xxhdx1985126 commented Aug 23, 2022 •

Copy link
Copy Markdown
Member

After this optimization, total cpu time spent in FixedKVBtree::lower_bound drops from 23.4% to 15.1%:

Before:
image
After:
image

Total cpu time spent doing FixedKVBtree related operations drops from 27.4 % to 20.5%

Before:
image
After:
image

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@xxhdx1985126

Copy link
Copy Markdown
Member Author

I'm still trying to optimize the code and add unit tests

@xxhdx1985126
xxhdx1985126 force-pushed the wip-intra-fixedkvbtree-pointers-2 branch from 3dd65c0 to 7e310c8 Compare August 24, 2022 02:07
@cyx1231st
cyx1231st self-requested a review August 24, 2022 05:17
@xxhdx1985126
xxhdx1985126 force-pushed the wip-intra-fixedkvbtree-pointers-2 branch from 7e310c8 to d8cbf9e Compare August 29, 2022 01:55
@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins retest this please

@xxhdx1985126
xxhdx1985126 force-pushed the wip-intra-fixedkvbtree-pointers-2 branch from c352ccc to e8b716a Compare August 29, 2022 09:50
@xxhdx1985126
xxhdx1985126 marked this pull request as ready for review August 29, 2022 09:52
@xxhdx1985126
xxhdx1985126 requested a review from a team as a code owner August 29, 2022 09:52
@xxhdx1985126
xxhdx1985126 force-pushed the wip-intra-fixedkvbtree-pointers-2 branch 3 times, most recently from 748fb97 to 2fb83c8 Compare August 31, 2022 03:31
@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check

@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check arm64

@xxhdx1985126
xxhdx1985126 force-pushed the wip-intra-fixedkvbtree-pointers-2 branch 8 times, most recently from 9023237 to 24fea12 Compare August 31, 2022 10:27
@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check

@athanatos athanatos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm about halfway through the branch. It would help me to have a short, precise description of how the tracker, btree node, and transaction relate, presumably in btree_child_tracker.h. I'll pick the review back up once that's added.

Comment thread src/crimson/os/seastore/cached_extent.h Resolved
Comment thread src/crimson/os/seastore/cached_extent.h Resolved
Comment thread src/crimson/os/seastore/cached_extent.h Resolved
Comment thread src/crimson/os/seastore/transaction.h Resolved
Comment thread src/crimson/os/seastore/cached_extent.h Resolved
Comment thread src/crimson/os/seastore/cached_extent.h Resolved
Comment thread src/crimson/os/seastore/cache.cc Resolved
Comment thread src/crimson/os/seastore/cached_extent.h Resolved
…rought the backref tree

After involving intra-fixed-kv-btree parent-child pointers, we need to keep the
invariant that it's only when extents are not in transactions' read_set that
we can directly query cache with inspecting the transaction

Signed-off-by: Xuehan Xu <[email protected]>
…h leaf nodes with(out) children

Signed-off-by: Xuehan Xu <[email protected]>
TransactionManager::read_pin()

Signed-off-by: Xuehan Xu <[email protected]>
@xxhdx1985126
xxhdx1985126 force-pushed the wip-intra-fixedkvbtree-pointers-2 branch from db2d13e to 33b56a0 Compare May 9, 2023 06:14
@xxhdx1985126

Copy link
Copy Markdown
Member Author

The following tests FAILED:
5 - setup-venv-for-mgr-dashboard-py3 (Failed)
7 - run-tox-mgr-dashboard-py3 (Not Run)
14 - setup-venv-for-mgr-dashboard-openapi (Failed)
16 - run-tox-mgr-dashboard-openapi (Not Run)

@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check

@cyx1231st

Copy link
Copy Markdown
Member

The build looks good!

Let's freeze the change and merge once the make check is good.

My local test shows the avg IOPS goes from ~2550 to ~2745:

./bin/rados bench -p test-pool 200 write -b 4096 --concurrent-ios=64 --no-cleanup

@xxhdx1985126

Copy link
Copy Markdown
Member Author

jenkins test make check

@cyx1231st
cyx1231st merged commit 785f3ec into ceph:main May 9, 2023
@cyx1231st

Copy link
Copy Markdown
Member

@xxhdx1985126 let me know if there are changes related to the unaddressed comments.

@xxhdx1985126

Copy link
Copy Markdown
Member Author

@xxhdx1985126 let me know if there are changes related to the unaddressed comments.

OK:-)

@myoungwon

Copy link
Copy Markdown
Member

I am not sure this is the right place to ask a question. Anyway, I recently encountered a seg fault because the osd accesses an invalid extent (already freed) during the rados test while RANDOM_BLOCK_SSD is enabled (./bin/rados bench -p testpool 60 write -t 32 -b 4K --no-cleanup). From my observation, onode_manager->get_or_create_onode try to retrieve old information about the pin's parent. During the search iteration, get_pin() returns a correct paddr like LBAMapping(18375522108508733440~16384->paddr<Dev(128),5369872384>.
Note that paddr<Dev(128),5369872384> is ONODE_BLOCK_STAGED and this was mutated before the get_pin().
But, the pin, the result of get_pin(), has a wrong parent pointer (seems that the parent pointer is not updated after a transaction is done). As a result, get_logical_child() accesses a child, which was invalid by the recent mutation (the prior pointer). I found that there is a condition to check the pointer is invalid, but just accessing it causes a seg fault.

Am I missing something? @xxhdx1985126 @cyx1231st

@cyx1231st

This comment was marked as duplicate.

@cyx1231st cyx1231st left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is the right place to ask a question.

It is fine to discuss in the related PR. I just started a thread so the related discussions can be chained together.

//TODO: can this search be avoided?
auto off = parent->lower_bound_offset(laddr);
assert(parent->get_key_from_idx(off) == laddr);
parent->children[off] = this;

@cyx1231st cyx1231st Jun 6, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @xxhdx1985126

Note that paddr<Dev(128),5369872384> is ONODE_BLOCK_STAGED and this was mutated before the get_pin().
But, the pin, the result of get_pin(), has a wrong parent pointer (seems that the parent pointer is not updated after a transaction is done).

See

* 1. if nodes are stable:
* a. parent points at the node's stable parent
* b. prior_instance is empty
* c. child pointers point at stable children. Child resolution is done
* directly via this array.
* c. copy_sources is empty
* 2. if nodes are mutation_pending:
* a. parent is empty and needs to be fixed upon commit
* b. prior_instance points to its stable version
* c. child pointers are null except for initial_pending() children of
* this transaction. Child resolution is done by first checking this
* array, and then recursively resolving via the parent. We copy child
* pointers from parent on commit.
* c. copy_sources is empty

There is an invariant that parent and children must always point to each other symmetricly before and after the commit. Seems your observation reflects this invarient is somehow broken. This should be the related logic to update the pointers between the LBALeaf and the LogicalCachedExtent(e.g. Onode) upon commit. Probably worth digging why the parent and children pointers are broken under the specific scenario.

As a result, get_logical_child() accesses a child, which was invalid by the recent mutation (the prior pointer). I found that there is a condition to check the pointer is invalid, but just accessing it causes a seg fault.

@myoungwon Can you show the entire call stack about where the seg faulted check happens? Does it happen without RBM?

@myoungwon myoungwon Jun 6, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking for a way to share the log.

osd0.log: https://drive.google.com/file/d/1E3_wKRPKRLjIPVqSOT7b8due2yJiAYZV/view?usp=sharing
osd0.stdout: https://drive.google.com/file/d/1hpAakO-kimTbCQVxny933QJFbY4YsGcl/view?usp=sharing

Can you see the above logs (please understand the manual logs for debugging I added)? Note that I just added logs, not touching existing code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you see the above logs (please understand the manual logs for debugging I added)?

Yes, I'm reading it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@myoungwon myoungwon Jun 6, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is main. I just added a few lines for logging (not related to seastore's operations). You can reproduce this by changing seastore_main_device_type in src/common/options/crimson.yaml.in to RANDOM_BLOCK_SSD. Then, run vstart.sh with rados bench.

@xxhdx1985126 xxhdx1985126 Jun 7, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyx1231st @myoungwon This issue should be fixed by #51948, please take a look.

The root cause is that I did all lba pointer adjustments of newly created lba nodes in the prepare_write interface which is invoked on ool extents before the transaction goes into the prepapre phase.

This was alright in segmented device scenarios because all lba/backref nodes are inline, which is not true for random block devices.

assert(child);
assert(child == cnode.get());
assert(cnode->is_parent_valid());
} else {

@cyx1231st cyx1231st Jun 9, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXIST_CLEAN and EXIST_MUTATION_PENDING child_node seem to be falling into this else case, which should be wrong because the else case expects the child_node is stable.

This issue was observed during testing #51179 which depends on the EXIST_CLEAN/PENDING features.

Probably need to scan other places as well to make sure EXIST_CLEAN and EXIST_MUTATION_PENDING extents are correctly handled with the lba tree pointers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #51980

@xxhdx1985126

Copy link
Copy Markdown
Member Author

My comments are mostly about how to constrain the impacts to the existing SeaStore components and abstraction.

Seems there are considerable lookup efforts can be excluded when get extents from Cache, with the p2c tracking, see the comments below.

Some comments are not addressed above:

It seems that I forgot to address some of these comments. I mark this up here and am getting into it.

@cyx1231st

Copy link
Copy Markdown
Member

I'm keeping the label "crimson-has-followup" here.

The following comments seem still valid and probably worth revisiting after the above 2 PRs when time allows:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants