Skip to content

crimson/os/seastore/segment_cleaner: misc cleanups and improvements - #46158

Merged
athanatos merged 18 commits into
ceph:masterfrom
cyx1231st:wip-seastore-cleaner
May 16, 2022
Merged

athanatos merged 18 commits into
ceph:masterfrom
cyx1231st:wip-seastore-cleaner

Conversation

@cyx1231st

Copy link
Copy Markdown
Member

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

@cyx1231st
cyx1231st requested a review from a team as a code owner May 5, 2022 07:41
@cyx1231st
cyx1231st force-pushed the wip-seastore-cleaner branch from 972a07b to 52fb032 Compare May 5, 2022 09:59
@athanatos

Copy link
Copy Markdown
Contributor

This PR seems to modify dirty_tail/_limit to only advance on segment bounds. I think that's going to tend to cause us to clean entries in larger chunks and introduce more latency variance in the future. I think I'd prefer to preserve the ability to represent/clean dirty entries within a segment in chunks smaller than a full segment.

@cyx1231st

cyx1231st commented May 10, 2022 •

Copy link
Copy Markdown
Member Author

This PR seems to modify dirty_tail/_limit to only advance on segment bounds. I think that's going to tend to cause us to clean entries in larger chunks and introduce more latency variance in the future. I think I'd prefer to preserve the ability to represent/clean dirty entries within a segment in chunks smaller than a full segment.

I think it is reasonable to preserve the ability to set trim target/limit within the segment, but IIUC the previous implementation is broken as we didn't set the correct segment-id to seq.offset.get_segment_id(). So that the comparison to the tail journal_seq_t will not work correctly according to https://github.com/ceph/ceph/blob/52fb032cd54056275a24de51747c0ef8a2699ef6/src/crimson/os/seastore/seastore_types.h#L770

So I thought the simplest workaround was to reset the offset to P_ADDR_MIN. The real fix might need to modify the journal_seq_t comparison to only consider seq.segment_seq and seq.offset.get_segment_off(). What do you think?

Fixed in d84fae3

@cyx1231st
cyx1231st force-pushed the wip-seastore-cleaner branch from 52fb032 to 6ebcee1 Compare May 10, 2022 09:56
@cyx1231st

Copy link
Copy Markdown
Member Author

Changeset:

  • Address reviews;
  • New commits to refine&improve segment cleaner metrics, starting from commit crimson/os/seastore/segment_cleaner: refine metrics)

@cyx1231st

Copy link
Copy Markdown
Member Author

6 new graph to understand, from the refined metrics:
1
2
3
4
5
6

@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins test api

@athanatos

Copy link
Copy Markdown
Contributor

This PR seems to modify dirty_tail/_limit to only advance on segment bounds. I think that's going to tend to cause us to clean entries in larger chunks and introduce more latency variance in the future. I think I'd prefer to preserve the ability to represent/clean dirty entries within a segment in chunks smaller than a full segment.

I think it is reasonable to preserve the ability to set trim target/limit within the segment, but IIUC the previous implementation is broken as we didn't set the correct segment-id to seq.offset.get_segment_id(). So that the comparison to the tail journal_seq_t will not work correctly according to

https://github.com/ceph/ceph/blob/52fb032cd54056275a24de51747c0ef8a2699ef6/src/crimson/os/seastore/seastore_types.h#L770

So I thought the simplest workaround was to reset the offset to P_ADDR_MIN. The real fix might need to modify the journal_seq_t comparison to only consider seq.segment_seq and seq.offset.get_segment_off(). What do you think?

Fixed in d84fae3

Arguably, we should just remove segment_id from journal_seq_t. That can wait for another PR though.

Comment thread src/crimson/os/seastore/cache.cc Outdated

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.

This will still result in an underestimate of the total space used since the sum of extent_info_t's of a record won't be equal to the full size of the header (deltas, etc). Is it worth adding this complexity just to reduce the severity of that underestimate? Moreover, for usage ratio calculations, arguably a segment with a disproportionate amount of overhead really should be have a lower utilization ratio. I'm not sure this is worth 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.

Agreed, dropped the commit.

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.

Where are we doing this comparison? I'm a bit leery of a tuple comparison that ignores one of the elements. It may be correct in the case you are fixing, but I worry that future users will be surprised by this behavior. I think other than this, we could:

  • remove segment_id from journal_seq_t
  • add a different journal_seq_t::cmp_seq_offset() static method with this behavior and update the caller
  • change the comparison from (seq, id, offset) to (seq, offset, id) rather than to (seq, offset)

@cyx1231st cyx1231st May 11, 2022 •

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.

change the comparison from (seq, id, offset) to (seq, offset, id) rather than to (seq, offset)

See 4a7fe81, I think this option is more appropriate as most of the users of journal_seq_t needs the physical location from segment-id, such as journal-tail, scan_valid_records_cursor and write_result_t.

Where are we doing this comparison?

As far as I know:

if (dirty_from < seq) {
TRACET("next extent -- {}", t, *i);
if (!cand.empty() && cand.back()->get_dirty_from() > dirty_from) {

(get_dirty_tail_limit() > journal_tail_target)

(get_dirty_tail_limit() > journal_tail_target)

void SegmentCleaner::update_journal_tail_target(journal_seq_t target)
{
logger().debug(
"{}: {}, current tail target {}",
__func__,
target,
journal_tail_target);
assert(journal_tail_target == JOURNAL_SEQ_NULL || target >= journal_tail_target);
if (journal_tail_target == JOURNAL_SEQ_NULL || target > journal_tail_target) {
journal_tail_target = target;
}
gc_process.maybe_wake_on_space_used();
maybe_wake_gc_blocked_io();
}
void SegmentCleaner::update_journal_tail_committed(journal_seq_t committed)
{
if (journal_tail_committed == JOURNAL_SEQ_NULL ||
committed > journal_tail_committed) {
logger().debug(
"{}: update journal_tail_committed {}",
__func__,
committed);
journal_tail_committed = committed;
}
if (journal_tail_target == JOURNAL_SEQ_NULL ||
committed > journal_tail_target) {
logger().debug(
"{}: update journal_tail_target {}",
__func__,
committed);
journal_tail_target = committed;
}
}

void scan_valid_records_cursor::emplace_record_group(
const record_group_header_t& header, ceph::bufferlist&& md_bl)
{
auto new_committed_to = header.committed_to;
ceph_assert(last_committed == JOURNAL_SEQ_NULL ||
last_committed <= new_committed_to);
last_committed = new_committed_to;
pending_record_groups.emplace_back(
seq.offset,
header,
std::move(md_bl));
increment_seq(header.dlength + header.mdlength);
ceph_assert(new_committed_to == JOURNAL_SEQ_NULL ||
new_committed_to < seq);
}

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.

This usage of 11 and 12 is pretty magic. At the very least add constants, but I think segment_util should probably just have two extra members.

@cyx1231st cyx1231st May 11, 2022 •

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.

Fixed in 6aa0894

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.

See above, I think this would be a bit too tough for a reader to follow.

@cyx1231st cyx1231st May 11, 2022 •

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.

Fixed in 6aa0894

@athanatos

Copy link
Copy Markdown
Contributor

LGTM other than the questions I left above.

@cyx1231st
cyx1231st force-pushed the wip-seastore-cleaner branch 2 times, most recently from 8d58751 to 02a3ce3 Compare May 11, 2022 12:13
@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

@cyx1231st
cyx1231st force-pushed the wip-seastore-cleaner branch from 02a3ce3 to cff6a82 Compare May 12, 2022 08:01
@cyx1231st

cyx1231st commented May 12, 2022 •

Copy link
Copy Markdown
Member Author

Changeset:

  • rebased
  • fix metrics after rebasing onto the backref-tree: cff6a82

@cyx1231st

Copy link
Copy Markdown
Member Author
...
DEBUG 2022-05-13 10:42:55,012 [shard 0] seastore_t - 0x615000598d80 Cache::create_transaction: created name=trim_backref, source=TRIM_BACKREF, is_weak=false
DEBUG 2022-05-13 10:42:55,012 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert_from_cache: insert up to journal_seq_t(segment_seq=1, offset=paddr_t<[0,9], 40960>)
DEBUG 2022-05-13 10:42:55,012 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert_from_cache: backref buffer starting seq: journal_seq_t(segment_seq=1, offset=paddr_t<[0,3], 16384>)
DEBUG 2022-05-13 10:42:55,012 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: seq journal_seq_t(segment_seq=1, offset=paddr_t<[0,3], 16384>), limit journal_seq_t(segment_seq=1, offset=paddr_t<[0,9], 40960>), num_fresh_backref 0
DEBUG 2022-05-13 10:42:55,012 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: remove mapping: paddr_t<[0,3], 8192>
DEBUG 2022-05-13 10:42:55,012 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: new mapping: paddr_t<[0,3], 20480>~8192 -> 8192
DEBUG 2022-05-13 10:42:55,012 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 8192~8192, paddr=paddr_t<[0,3], 20480>
DEBUG 2022-05-13 10:42:55,012 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 8192~8192, paddr=paddr_t<[0,3], 20480>, state: end, insert at paddr_t<[0,3], 20480>
DEBUG 2022-05-13 10:42:55,013 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: new mapping: paddr_t<[0,3], 28672>~8192 -> 16384
DEBUG 2022-05-13 10:42:55,013 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 16384~8192, paddr=paddr_t<[0,3], 28672>
DEBUG 2022-05-13 10:42:55,013 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 16384~8192, paddr=paddr_t<[0,3], 28672>, state: end, insert at paddr_t<[0,3], 28672>
DEBUG 2022-05-13 10:42:55,013 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: new mapping: paddr_t<[0,3], 36864>~4096 -> 0
DEBUG 2022-05-13 10:42:55,013 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 0~4096, paddr=paddr_t<[0,3], 36864>
DEBUG 2022-05-13 10:42:55,014 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 0~4096, paddr=paddr_t<[0,3], 36864>, state: end, insert at paddr_t<[0,3], 36864>
DEBUG 2022-05-13 10:42:55,014 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: seq journal_seq_t(segment_seq=1, offset=paddr_t<[0,3], 40960>), limit journal_seq_t(segment_seq=1, offset=paddr_t<[0,9], 40960>), num_fresh_backref 0
DEBUG 2022-05-13 10:42:55,014 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: remove mapping: paddr_t<[0,3], 28672>
DEBUG 2022-05-13 10:42:55,014 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: new mapping: paddr_t<[0,3], 49152>~8192 -> 24576
DEBUG 2022-05-13 10:42:55,014 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 24576~8192, paddr=paddr_t<[0,3], 49152>
DEBUG 2022-05-13 10:42:55,015 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 24576~8192, paddr=paddr_t<[0,3], 49152>, state: end, insert at paddr_t<[0,3], 49152>
DEBUG 2022-05-13 10:42:55,015 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: new mapping: paddr_t<[0,3], 57344>~8192 -> 32768
DEBUG 2022-05-13 10:42:55,015 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 32768~8192, paddr=paddr_t<[0,3], 57344>
DEBUG 2022-05-13 10:42:55,015 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::new_mapping: 32768~8192, paddr=paddr_t<[0,3], 57344>, state: end, insert at paddr_t<[0,3], 57344>
DEBUG 2022-05-13 10:42:55,015 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: seq journal_seq_t(segment_seq=1, offset=paddr_t<[0,3], 65536>), limit journal_seq_t(segment_seq=1, offset=paddr_t<[0,9], 40960>), num_fresh_backref 0
DEBUG 2022-05-13 10:42:55,015 [shard 0] seastore_backref - 0x615000598d80 BtreeBackrefManager::batch_insert: seq journal_seq_t(segment_seq=3, offset=paddr_t<[0,9], 12288>), limit journal_seq_t(segment_seq=1, offset=paddr_t<[0,9], 40960>), num_fresh_backref 0
DEBUG 2022-05-13 10:42:55,016 [shard 0] seastore_t - 0x615000599000 Cache::create_transaction: created name=trim_journal, source=CLEANER_TRIM, is_weak=false
DEBUG 2022-05-13 10:42:55,016 [shard 0] seastore_tm - 0x615000599000 TransactionManager::get_next_dirty_extents: max_bytes=1048576B, seq=journal_seq_t(segment_seq=1, offset=paddr_t<[0,9], 40960>)
DEBUG 2022-05-13 10:42:55,016 [shard 0] seastore_cleaner - 0x615000599000 SegmentCleaner::rewrite_dirty: rewrite 1 dirty extents
DEBUG 2022-05-13 10:42:55,016 [shard 0] seastore_cleaner - 0x615000599000 SegmentCleaner::rewrite_dirty: cleaning CachedExtent(addr=0x61200044e0c0, type=OMAP_INNER, version=6, dirty_from_or_retired_at=journal_seq_t(segment_seq=1, offset=paddr_t<[0,3], 40960>), last_modified=1652409728.000000000s, last_rewritten=0.000000000s, paddr=paddr_t<[0,3], 36864>, length=4096, state=DIRTY,               last_committed_crc=4114115439, refcount=3, laddr=0, pin=LBAPin(0~4096->paddr_t<[0,3], 36864>, size=12, depth=2)
DEBUG 2022-05-13 10:42:55,016 [shard 0] seastore_tm - 0x615000599000 TransactionManager::rewrite_logical_extent: rewriting extent -- CachedExtent(addr=0x61200044e0c0, type=OMAP_INNER, version=6, dirty_from_or_retired_at=journal_seq_t(segment_seq=1, offset=paddr_t<[0,3], 40960>), last_modified=1652409728.000000000s, last_rewritten=0.000000000s, paddr=paddr_t<[0,3], 36864>, length=4096,         state=DIRTY, last_committed_crc=4114115439, refcount=7, laddr=0, pin=LBAPin(0~4096->paddr_t<[0,3], 36864>, size=12, depth=2) to CachedExtent(addr=0x61200042d6c0, type=OMAP_INNER, version=0, dirty_from_or_retired_at=JOURNAL_SEQ_NULL, last_modified=1652409728.000000000s, last_rewritten=0.000000000s, paddr=paddr_t<DELAYED_TEMP>, length=4096, state=INITIAL_WRITE_PENDING, last_committed_crc=0,     refcount=2, laddr=0, pin=LBAPin(0~4096->paddr_t<[0,3], 36864>, size=12, depth=2)
ERROR 2022-05-13 10:42:55,017 [shard 0] seastore_backref - 0x615000599000 BtreeBackrefManager::remove_mapping: paddr=paddr_t<[0,3], 36864> doesn't exist

@xxhdx1985126 from the above log, seems the trim_backref transaction 0x615000598d80 is trying to insert paddr_t<[0,3], 36864> into the tree. But before 0x615000598d80 is successful committed, the trim_journal transaction 0x615000599000 somehow tries to remove paddr_t<[0,3], 36864> from the tree.

@xxhdx1985126

Copy link
Copy Markdown
Member

@xxhdx1985126 from the above log, seems the trim_backref transaction 0x615000598d80 is trying to insert paddr_t<[0,3], 36864> into the tree. But before 0x615000598d80 is successful committed, the trim_journal transaction 0x615000599000 somehow tries to remove paddr_t<[0,3], 36864> from the tree.

Yeah, I've found the root cause, and am testing the fix, the pr of which should be submitted later today:-)

@cyx1231st
cyx1231st force-pushed the wip-seastore-cleaner branch from cff6a82 to f04a31c Compare May 13, 2022 04:26
@cyx1231st

Copy link
Copy Markdown
Member Author

Yeah, I've found the root cause, and am testing the fix, the pr of which should be submitted later today:-)

Thanks!

Rebased.

cyx1231st added 18 commits May 13, 2022 15:51
* unify update_segment_avail_bytes() and set_journal_head() interfaces.
* reuse segment_info_t::written_to to get the current journal head.
* more strict validations about journal head maintainence.

Signed-off-by: Yingxin Cheng <[email protected]>
…nreclaimable and reclaimable

Signed-off-by: Yingxin Cheng <[email protected]>
@cyx1231st
cyx1231st force-pushed the wip-seastore-cleaner branch from f04a31c to 538f955 Compare May 13, 2022 07:52
@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins test api

@athanatos
athanatos self-requested a review May 16, 2022 21:05
@athanatos
athanatos merged commit 86aacf1 into ceph:master May 16, 2022
@cyx1231st
cyx1231st deleted the wip-seastore-cleaner branch May 17, 2022 01:51
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.

3 participants