Repository navigation
Conversation
ec9ffb1 to
de134c0
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
| if (populate_slot) { | ||
| DEBUGT("[onode_cache] stored resolved onode in slot", | ||
| *ctx.transaction); | ||
| slot_ref->resolved_onode = std::make_shared<OnodeRef>(onode); |
There was a problem hiding this comment.
The "write-back" approach here seems to open a gate for various bugs. Without it, as the commit message explains, for newly created objects, we cache obcs with empty onode cache slot - until the obc is then reloaded the slot would remain null.
I tried avoiding it by writing back to the obc slot from within seastore - but this exposes the onode at uncommitted state with troubles plenty of seastore internal structures (most notably extent mutability states are broken, since we try to reuse the extent at random states which is not well defined).
I think I'll go ahead with reverting this and falling back to a more stable version and see if we can perhaps manage the cached empty-onode-slot obcs differently at the osd level (re-reload?).
| struct OnodeCacheSlot { | ||
| ghobject_t oid; | ||
| std::shared_ptr<void> onode; |
There was a problem hiding this comment.
Initial testing, the assumption here of obj:txn is wrong - it should either move to a obj:txn-op or obj_map:txn. To be updated.
| assert(store_active); | ||
| ++(shard_stats.read_num); | ||
| ++(shard_stats.pending_read_num); | ||
| std::shared_ptr<void> onode_handle; |
There was a problem hiding this comment.
It seems that seastar::shared_ptr/seastar::lw_shared_ptr might be better, since it would avoid facilities for ensuring thread safety. Am I right?
There was a problem hiding this comment.
I mentioned in the commit message that the reason was to avoid this in Transaction.h though I might use ifdef:
std::shared_ptr<void> is used (rather than seastar::lw_shared_ptr) to keep
this common header free of seastar deps.
wdyt?
There was a problem hiding this comment.
It looks to me that, since we already wrap the related code in ceph::os::Transaction with WITH_CRIMSON, it wouldn't hurt to use seastar::shared_ptr<>/seastore::lw_shared_ptr<> there, although it adds seastar deps, am I right?
There was a problem hiding this comment.
Will address once the PR design and bug fixes are ready
|
There's one more thing, i think we can attach the pg meta object's onode to the corresponding pg, so there won't be extra onode tree searches for updating the pglog and pg info. Am i right? |
de134c0 to
d579193
Compare
d579193 to
ed14e72
Compare
Thanks for looking!
Interesting, it should be possible with this design. I'll look into it once this is stable enough. @xxhdx1985126, Added |
Config Diff Tool Output+ added: seastore_onode_cache_bypass (crimson.yaml.in)
The above configuration changes are found in the PR. Please update the relevant release documentation if necessary. |
fae2b22 to
8bb276d
Compare
xxhdx1985126
left a comment
There was a problem hiding this comment.
Still looking, added some comments for now.
| @@ -1926,6 +1926,12 @@ SeaStore::Shard::_do_transaction_step( | |||
| op->op == Transaction::OP_ZERO) { | |||
| create = true; | |||
| } | |||
|
|
|||
| if (onodes[op->oid] && !onodes[op->oid]->is_reusable()) { | |||
There was a problem hiding this comment.
IIUC, this might reduce the performance gain expected by this PR, maybe we can do some onode tree leaf node merging like the lba nodes in the future, if the leaf extent is only mutated and not split/merged. WDYT?
There was a problem hiding this comment.
Strongly Agree - though I think we would need to first make this version of the PR ready for merging.
Later on, I can start looking at Onode in-flight merging to reduce conflicts and also catch the onode reusable definition suggested here.
I think that LBA nodes would (hopefully) make more sense to support merging first and then Onode ones as backref is already there. wdyt?
| @@ -365,6 +365,13 @@ class NodeExtentAccessorT { | |||
| // for the safety of mixed read and mutate, call before read. | |||
| void prepare_mutate(context_t c) { | |||
| assert(!is_retired()); | |||
| // Reusing cached FLTreeOnode curosr path: | |||
| if ((state == nextent_state_t::MUTATION_PENDING || | |||
| state == nextent_state_t::FRESH) && extent->is_stable()) { | |||
There was a problem hiding this comment.
Although this may not be causing any trouble for now, but, after all, there would be a period of time when the state is inconsistent with the node, which breaks the corresponding invariant.
Maybe we can reset this state when the last transaction commits, like tree_cursor_t::Cache::invalidate().
There was a problem hiding this comment.
Looking into this, considering a new nextent_state_t will update
There was a problem hiding this comment.
I think resetting at commit time similar to Cache::invalidate() won't work, after digging a bit - CachedExtent layer has no reference back to the accessor (NodeExtentAccessorT) that we want to reset. Unlike invalidate() which is possible since the cursor owns its cache (tree_cursor_t::cache).
I also tried eager reset instead of the prepare_mutate stage, but the problem is that not only the new path would hit the stale state but also a regular get_onode lookups hits it. So reseting later than the mutation entry would reintroduce the maybe_duplicate() stale-version case.
A new nextent_state_t also doesn't help, the issue isn't a missing state, it's that the existing state outlives the txn itself.
I agree that the state is briefly inconsistent until we reset it. I've moved this logic into a reset_after_commit to make this more clear.
wdyt?
There was a problem hiding this comment.
I think it's ok to leave this to later work, let's add a TODO comment for this, what do you think?
8bb276d to
86c02e5
Compare
|
Re-based with round of fixes, stable than before I was able to test this without crashes on a prefilled image. todo:
followup:
|
Before submitting the write transaction, attach the cached_onode to the transaction. SeaStore will use resuse it in _do_transaction_step if valid to avoid the lookup. Signed-off-by: Matan Breizman <[email protected]>
Used to verify that the cursor of the onode is still valid before reusing it across transaction boundaries. An untracked cursor means the underlying extent was evicted or invalidated. The obc-cached onode cursor can have its leaf extent invalidated by GC between the obc load and the write transaction that tries to reuse it. Signed-off-by: Matan Breizman <[email protected]>
*Note: key commit* If the txn has onode_cache that is safe to use - assign it directly to onodes[] and skip the onode_manager lookup. Signed-off-by: Matan Breizman <[email protected]>
592b0fe to
4089253
Compare
|
I'm re-thinking the design and its scope to decide the next-steps.
I think that I should go here with option 1 given its stable(ish). However, its only improving the I'll measure the benefit prior to merging this on an expected workload. Either pre-filling an image and restarting the osd to force reload of exsiting objects, or reducing obc cache size to (again) force reloads - and compare with ad without this PR. Note: I'll continue looking into the onode lookup stage, we might miss something in the internal implementation (node sizes, cursor caching. CC: @xxhdx1985126, @jdurgin |
IIUC, with this option, the perf gain comes from:
Is this correct? If so, I think Option 1 is a good start, as it is much simpler than Option 2. And we can always go on with Option 2 later if the perf tests prove its necessity. |
Exactly. PR should be ready for review then, I'll start running tests to verify the state. |
| @@ -365,6 +365,13 @@ class NodeExtentAccessorT { | |||
| // for the safety of mixed read and mutate, call before read. | |||
| void prepare_mutate(context_t c) { | |||
| assert(!is_retired()); | |||
| // Reusing cached FLTreeOnode curosr path: | |||
| if ((state == nextent_state_t::MUTATION_PENDING || | |||
| state == nextent_state_t::FRESH) && extent->is_stable()) { | |||
There was a problem hiding this comment.
I think it's ok to leave this to later work, let's add a TODO comment for this, what do you think?
| @@ -370,13 +370,19 @@ class ParentNode { | |||
| auto child = children[pos]; | |||
| ceph_assert(!is_reserved_ptr(child)); | |||
| if (is_valid_child_ptr(child)) { | |||
| if (!static_cast<ChildT*>(child)->is_valid()) { | |||
There was a problem hiding this comment.
I don't quite follow this part, could you elaborate a bit more about the issue you met?
There was a problem hiding this comment.
This is really exposed due to the onode-cache opens a gate where we might invalidate an extent but the parent would still hold a link - similar to the other fixes here (is_reusable and get_or_track_child fix).
all child node accessors (move_child_ptrs, adjust_ptracker_for_children) assume is_valid implicitly. The problem is we when we set_invalid we only reset_parent_tracker to clear the child to parent link. But the parent to child link (`children[pos]) used above is not cleared.
This would hit assert(is_valid) later on.
I'll update the commit message to better describe this.
There was a problem hiding this comment.
IIRC, when we do set_invalid() for an extent, its parent should have been redirected to another valid extent, like in the cases of the extent being rewriting/replacing/split/merged.
It looks to me that, even if with onode-cache, the above invariant should have been held. Am I missing something?
There was a problem hiding this comment.
For rewriting/replacing/split/merged the parent is redirected (take_parent_from_prior sets children[off] = next) - so the parent never points at the stale instance. Agreed there.
But that redirect is the only thing keeping the invariant.
set_invalid() itself doesn’t help here - it only calls reset_parent_tracker() - Meaning, it clears the child to parent side.
The parent to child raw pointer in children[] is never touched on invalidation.
children[pos] is only cleared by:
- on_replace_prior - the redirect paths mentioned above
destroy()(children[off] = nullptr) - but we only destroy() stable extents (~LogicalChildNodeskips INVALID ones).
So a "parent pointing to INVALID child” issue fixes here is never actively cleared.
Normally that’s fine because the invalid extent is freed (extent removed).
The onode-cache introduces a holder in the commit path doesn’t drop invalid extent. A cached OnodeRef now could outlive the txn. So the invalid extent (and the stale children link) survives.
Then on actual node reuse we can still reach it - get_child would crash on assert(is_valid()).
There was a problem hiding this comment.
I think, when an extent turns invalid, its parent LBA leaf node's corresponding pointer should have been pointed to another valid one. So, even if an invalid onode extent still lives in Cache due to the cached onode, there should be no LBA leaf node pointing to it.What was the case in which this didn't hold?
There was a problem hiding this comment.
I'll revert this commit to share the specific case logs to we could discuss this more conveniently.
added for perf evaluation to avoid rebuilding Signed-off-by: Matan Breizman <[email protected]>
When obc->cached_onode hit in _do_transaction_step, we skip onode_manager->get_onode() which would have called read_extent() -> Cache::get_extent() -> t.add_to_read_set(leaf_extent). A later prepare_mutate() -> Cache::duplicate_for_write() -> Transaction::add_mutated_extent() asserts: read_set.count(ref->prior_instance->get_paddr()) and aborts because the leaf extent was never registered. Add Onode::register_with_transaction() to call add_cursor_leaf_to_read_set(), which calls t.add_to_read_set(leaf_extent) (guarded by is_in_read_set to be idempotent across multiple bypass oids sharing the same leaf). Signed-off-by: Matan Breizman <[email protected]>
SeastoreNodeExtent had no clear_delta() override, unlike FixedKVNode which
clears its delta_buffer after each commit.
DIRTY leaf extent kept its non-null recorder from the prior transaction.
When the same extent was later loaded by a new fltree traversal,
NodeExtentAccessorT's ctor failed:
assert(extent->get_recorder() == nullptr ||
extent->get_recorder()->is_empty())
Signed-off-by: Matan Breizman <[email protected]>
A cached FLTreeOnode cursor carries state=MUTATION_PENDING (or FRESH for new objects) in its NodeExtentAccessorT after the txn that wrote it commits. On the next write using the same cached onode, prepare_mutate() skips the READ_ONLY transition block and fails assert(extent->is_mutable()) with a now-stable (DIRTY) extent. Then recorder->get_value_recorder() is called with a raw pointer to the recorder that was freed by clear_delta() causing a heap-use-after-free caught by ASAN. detect a stale MUTATION_PENDING or FRESH state on a now-stable extent and reset to READ_ONLY so the normal READ_ONLY into MUTATION_PENDING path runs. Signed-off-by: Matan Breizman <[email protected]>
On FLTreeOnode cursor reuse reset the state changes from MUTATION_PENDING to READ_ONLY back to MUTATION_PENDING, making the before/after states identical even though the buffer was changed. Instead detect this by comparing buffer pointers. Signed-off-by: Matan Breizman <[email protected]>
A concurrent commit (replace/retire via invalidate_extent) may have invalidated this extent after it was linked. Treat as absent so the caller loads the current committed version via pin_to_extent. Signed-off-by: Matan Breizman <[email protected]>
…hild post-load A concurrent/conflicting commit invalidated the extent between Node::load above to the returning stage. Evict the stale node and set conflict for a clean retrn. Signed-off-by: Matan Breizman <[email protected]>
… reuse When the onode cache bypass reuses the same FLTreeOnode cursor across transactions, Cache::value_payload_mut and p_value_recorder were stale. Call the accessor unconditionally on every prepare_mutate_value_payload call, then run maybe_duplicate to detect any buffer change (if any). The accessor's prepare_mutate may detect that the underlying extent was committed since our last call and create a fresh copy. If it does, the buffer pointer changes. A second maybe_duplicate detects that change and updates p_value_header to point into the new extent before we get value_payload_mut. See: maybe_duplicate version.state == current_version.state With caching gone, p_value_recorder and cached_trans_id are no longer used. Signed-off-by: Matan Breizman <[email protected]>
4089253 to
786d470
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
|
This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution! |
This brings Onode awareness within Crimson-OSD's object context. While it's not optimal to break isolation between the layers. Trying to reuse cached Onode extents (even if all are cache hit) - still require:
read_extent(leaf_laddr)- cache (extent) map lookupnew LeafNode- wrapping the extentlower_bound()scan thorugh the leaf keys with fullhobject_tcomparison (<-- main cost)new FLTreeOnodealloc.For every write we first scan the onode tree in
get_obcstage then another time when actually performing the write.Keeping the Onode ref should save us the second lookup entirely. According to analysis made in #69281:
Another approach here could be, keeping OnodeRef cache layer directly within Seastore - However, this would essentially duplicate the object context cache management - obc loader, lru/2q (eviction, invalidation on interval change) so reusing obc for this purpose is simpler.
Lastly, reducing the above overhead might largely impact randwrite workloads - keeping as draft for early reviews until proven impact is seen (I'm hitting another bug which is exposed with the changes here that blocks this from being tested properly, I'll address it in another PR ).
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.