Skip to content

crimson/os/seastore: move ool writes from collection lock to concurrent DeviceSubmission phase - #58913

Merged
cyx1231st merged 15 commits into
ceph:mainfrom
cyx1231st:wip-seastore-unlock-ool
Aug 8, 2024
Merged

cyx1231st merged 15 commits into
ceph:mainfrom
cyx1231st:wip-seastore-unlock-ool

Conversation

@cyx1231st

@cyx1231st cyx1231st commented Jul 30, 2024 •

Copy link
Copy Markdown
Member

Essential changes:

  1. Refactor RecordSubmitter to make the write base available upon submitting ool writes.
  2. Refactors in ool to move necessary updates before ool writes, see commits:
    • "RandomBlockOolWriter to update extents upon submitting writes".
    • "SegmentedOolWriter to update ool paddr upon submitting writes".
  3. Move ool write futures into the concurrent DeviceSubmission phase, see commit:
    • "wait ool writes in DeviceSubmission phase".

The issue was observed from #58467, that there are many waiters blocked by the collection lock, and this PR tries to decouple (maybe slow) IO writes out of the lock.

The observed benefits are:

  1. The random write end-performance was improved by ~3 ~6% from local fio-rbd tests (1 OSD, 32 cores, fio-rbd).
  2. Reactor utilization was improved from ~89% to ~93% [1].
  3. The op concurrency (per-shard) outside (after) the collection lock was improved from ~1.4 to ~2.6 [2].

(Further analysis, unrelated to this PR)

However, this PR doesn't address the issue of "too many collection lock waiters" very well, my current understandings are:

  1. The overall reactor utilization is very high (~93%), meaning that CPU is already busy executing actual tasks (not starving), so making the critical logic efficient would be more benefitial in this case.
  2. The collection lock waiters are very unbalanced [3]:
    • They are varying from 0 up to 1400 waiters across the shards.
    • The pattern of the imbalanced waiters won't change during the tests, they are keeping piling up in the same shard.
    • The shards having excessive waiters have higher reactor utilizations (99% vs others 88%) and lower IOPS (4700 vs others 5200), impacting the end-performance.

[1] Reactor utilizations

Before:
INFO  2024-07-29 14:22:49,878 [shard  0:main] osd - OSD::start: reactor_utilizations: 89(91,99,96,84,89,90,99,99,87,85,88,90,91,82,88,89,91,83,85,96,89,91,90,91,98,82,84,91,90,76,72,73,)
INFO  2024-07-29 14:22:51,878 [shard  0:main] osd - OSD::start: reactor_utilizations: 88(90,99,96,83,89,91,99,99,87,84,87,90,92,81,88,88,91,81,84,95,90,91,89,90,98,81,85,90,90,76,72,74,)
INFO  2024-07-29 14:22:53,879 [shard  0:main] osd - OSD::start: reactor_utilizations: 88(90,99,95,82,88,91,99,99,88,83,87,90,91,81,88,88,90,81,85,96,89,90,89,89,98,81,84,91,88,76,73,73,)
INFO  2024-07-29 14:22:55,878 [shard  0:main] osd - OSD::start: reactor_utilizations: 88(91,99,97,82,87,92,99,99,88,82,86,90,90,82,90,88,90,82,85,96,90,91,89,88,98,82,84,92,89,76,74,74,)
...

After:
INFO  2024-07-29 13:45:22,400 [shard  0:main] osd - OSD::start: reactor_utilizations: 93(86,87,99,99,99,94,99,96,88,94,89,93,87,90,93,96,94,90,97,90,97,87,91,80,96,92,92,93,95,95,94,99,)
INFO  2024-07-29 13:45:24,400 [shard  0:main] osd - OSD::start: reactor_utilizations: 93(87,86,99,99,99,94,99,98,88,95,89,93,87,91,94,96,94,90,97,91,97,87,92,79,96,92,93,93,95,96,94,99,)
INFO  2024-07-29 13:45:26,401 [shard  0:main] osd - OSD::start: reactor_utilizations: 93(86,85,99,99,99,94,99,98,88,95,88,92,85,92,95,95,93,89,95,91,96,88,92,79,96,92,94,93,95,96,93,98,)
INFO  2024-07-29 13:45:28,401 [shard  0:main] osd - OSD::start: reactor_utilizations: 92(84,85,99,99,99,92,99,97,88,93,88,91,85,92,95,94,93,89,92,91,96,88,91,80,93,93,94,92,96,95,91,97,)
...

[2] SeaStore outstanding transactions (The 4th colume is outside the collection-lock, see *):

Before:
INFO  2024-07-29 14:22:45,879 [shard  0:main] seastore - SeaStore: trans outstanding per-shard: 105.81(0.00,101.59,0.00,2.62,*1.59*)
INFO  2024-07-29 14:22:47,878 [shard  0:main] seastore - SeaStore: trans outstanding per-shard: 100.12(0.00,96.16,0.00,2.44,*1.53*)
INFO  2024-07-29 14:22:49,878 [shard  0:main] seastore - SeaStore: trans outstanding per-shard: 102.81(0.00,99.44,0.00,2.19,*1.19*)
INFO  2024-07-29 14:22:51,878 [shard  0:main] seastore - SeaStore: trans outstanding per-shard: 101.22(0.00,97.50,0.00,2.31,*1.41*)
...

After:
INFO  2024-07-29 13:45:16,400 [shard  0:main] seastore - SeaStore: trans outstanding per-shard: 99.41(0.00,94.31,0.00,2.34,*2.75*)
INFO  2024-07-29 13:45:18,400 [shard  0:main] seastore - SeaStore: trans outstanding per-shard: 101.44(0.00,96.97,0.00,2.03,*2.44*)
INFO  2024-07-29 13:45:20,400 [shard  0:main] seastore - SeaStore: trans outstanding per-shard: 100.41(0.00,95.31,0.00,2.41,*2.69*)
INFO  2024-07-29 13:45:22,400 [shard  0:main] seastore - SeaStore: trans outstanding per-shard: 103.28(0.00,98.00,0.00,2.59,*2.69*)
...

[3] Persistent waiter imbalances:

The second colume means waiters (see *):
INFO  2024-07-29 13:45:14,400 [shard  0:main] seastore - SeaStore: details: 12(0,9,0,2,1) 3(0,0,0,1,2) 965(0,*958*,0,3,4) 536(0,528,0,4,4) 623(0,615,0,4,4) 2(0,0,0,0,2) ...
INFO  2024-07-29 13:45:16,400 [shard  0:main] seastore - SeaStore: details: 0(0,0,0,0,0) 18(0,11,0,4,3) 999(0,*991*,0,4,4) 521(0,514,0,3,4) 547(0,540,0,4,3) 29(0,21,0,4,4) ...
INFO  2024-07-29 13:45:18,400 [shard  0:main] seastore - SeaStore: details: 0(0,0,0,0,0) 1(0,0,0,0,1) 1159(0,*1152*,0,3,4) 518(0,512,0,4,2) 528(0,521,0,4,3) 23(0,17,0,3,3) ...
INFO  2024-07-29 13:45:20,400 [shard  0:main] seastore - SeaStore: details: 2(0,0,0,0,2) 9(0,5,0,1,3) 1160(0,*1152*,0,4,4) 426(0,418,0,4,4) 519(0,512,0,4,3) 39(0,34,0,3,2) ...

They are consistent with the pattern of reactor utilizations:
INFO  2024-07-29 13:45:14,400 [shard  0:main] osd - OSD::start: reactor_utilizations: 92(83,84,99,99,99,91...)
INFO  2024-07-29 13:45:16,400 [shard  0:main] osd - OSD::start: reactor_utilizations: 93(84,86,99,99,99,93...)
INFO  2024-07-29 13:45:18,400 [shard  0:main] osd - OSD::start: reactor_utilizations: 93(86,88,99,99,99,93...)
INFO  2024-07-29 13:45:20,400 [shard  0:main] osd - OSD::start: reactor_utilizations: 93(86,88,99,99,99,93...)

They are consistent with the pattern of IOPS:
INFO  2024-07-29 13:45:14,400 [shard  0:main] seastore - SeaStore: device IOPS: 166397.74 5199.93(5102.37,5179.87,4908.37,4955.87,4946.37,5347.86...)
INFO  2024-07-29 13:45:16,400 [shard  0:main] seastore - SeaStore: device IOPS: 176248.70 5507.77(5910.40,6137.38,4764.02,4842.51,4805.01,5414.95...)
INFO  2024-07-29 13:45:18,400 [shard  0:main] seastore - SeaStore: device IOPS: 174205.65 5443.93(6037.49,5712.44,4732.28,4734.78,4786.29,5557.91...)
INFO  2024-07-29 13:45:20,400 [shard  0:main] seastore - SeaStore: device IOPS: 170744.17 5335.76(5574.89,5768.39,4798.41,4866.91,4826.41,5468.89...)

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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
  • jenkins test rook e2e

@cyx1231st
cyx1231st requested a review from a team as a code owner July 30, 2024 03:06
@cyx1231st

Copy link
Copy Markdown
Member Author

make check is failed by:

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/protobuf/protobuf-targets.cmake:111 (message):
  The imported target "protobuf::protoc" references the file

     "/usr/bin/protoc-25.1.0"

  but this file does not exist.

Should be unrelated.

@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins test make check

@cyx1231st

Copy link
Copy Markdown
Member Author
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler

    "/usr/bin/clang++-14"

  is not able to compile a simple test program.

@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins test make check

@myoungwon myoungwon 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.

It looks good to me if the unit tests pass.

@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins retest this please

Decouple get_written_to() so it can be queried upon writes.

Signed-off-by: Yingxin Cheng <[email protected]>
…ilable

Make sure the write base is available upon RecordSubmitter::submit().

Signed-off-by: Yingxin Cheng <[email protected]>
No longer need to pass write_base through the write promise.

Signed-off-by: Yingxin Cheng <[email protected]>
…upon submit

For out-of-line write only.

Signed-off-by: Yingxin Cheng <[email protected]>
…submitting writes

In order to move the ool write futures out of the collection lock, which
will be after the transaction prepare phase.

Signed-off-by: Yingxin Cheng <[email protected]>
@cyx1231st
cyx1231st force-pushed the wip-seastore-unlock-ool branch from 79d2c51 to 14f9890 Compare August 5, 2024 03:32
@cyx1231st

Copy link
Copy Markdown
Member Author

make check is failed by:

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/protobuf/protobuf-targets.cmake:111 (message):
  The imported target "protobuf::protoc" references the file

     "/usr/bin/protoc-25.1.0"

@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins test make check

@cyx1231st
cyx1231st force-pushed the wip-seastore-unlock-ool branch from 14f9890 to e7693ee Compare August 5, 2024 05:48
@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins test make check

…submitting writes

In order to move the ool write futures out of the collection lock, which
will be after the transaction prepare phase.

Signed-off-by: Yingxin Cheng <[email protected]>
Drop the inaccurate written_ prefix because they may be still writting
when added to the lists.

Signed-off-by: Yingxin Cheng <[email protected]>
So that it is moved out of the collection lock.

Signed-off-by: Yingxin Cheng <[email protected]>
@cyx1231st
cyx1231st force-pushed the wip-seastore-unlock-ool branch from 25798ff to 19dbe68 Compare August 7, 2024 04:52
@cyx1231st

Copy link
Copy Markdown
Member Author

jenkins test api

@cyx1231st
cyx1231st merged commit eb9e05b into ceph:main Aug 8, 2024
@cyx1231st
cyx1231st deleted the wip-seastore-unlock-ool branch August 8, 2024 06:19
@xxhdx1985126

xxhdx1985126 commented Aug 17, 2024 •

Copy link
Copy Markdown
Member

@cyx1231st IIUC, after the merge of this PR, ool writes may be persisted to disk after the inline writes of the same transaction, is this correct? If so, this might be a problem, since the data can be persisted after the metadata, in which case SeaStore's ondisk state can be corrupted if a restart happens right after the persistence of the metadata but before that of the data.

Am I right?

I'm very sorry that I failed to notice this issue earlier.

@cyx1231st

Copy link
Copy Markdown
Member Author

@xxhdx1985126 Appriciate for your insights!

Yeah, you're correct that the journal record must be the last one to be written.

I'll revert the wrong commit.

@myoungwon

Copy link
Copy Markdown
Member

I have a question. It seems that this commit (c9e423f) intends to handle OOL writes before submitting records for inline writes. Plus, the device is opened with the dsync option. How could such a situation occur?

@xxhdx1985126

Copy link
Copy Markdown
Member

I have a question. It seems that this commit (c9e423f) intends to handle OOL writes before submitting records for inline writes. Plus, the device is opened with the dsync option. How could such a situation occur?

I think it's that there's no guarantee from the seastar side that the ool writes' I/O requests will be issued to the disk before that of the inline writes.

@cyx1231st

Copy link
Copy Markdown
Member Author

The commit (c9e423f) starts to submit OOL writes before submitting the journal write, true, but it cannot guarantee that OOL writes finish before the journal write.

Thus it is possible that during SeaStore restart, a journal record appears valid but its dependent OOL records are partial written, which leads to corruption.

@myoungwon

Copy link
Copy Markdown
Member

Thanks for explanation!

zhscn pushed a commit to zhscn/ceph that referenced this pull request Aug 28, 2024
…ock-ool"

This reverts commit eb9e05b, reversing
changes made to 44fc9fa.
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