Skip to content

os/bluestore: Add CoDel to BlueStore for Bufferbloat mitigation - #43413

Merged
athanatos merged 2 commits into
ceph:masterfrom
esmaeil-mirvakili:bluestore-bufferbloat-mitigation
Apr 22, 2022
Merged

athanatos merged 2 commits into
ceph:masterfrom
esmaeil-mirvakili:bluestore-bufferbloat-mitigation

Conversation

@esmaeil-mirvakili

@esmaeil-mirvakili esmaeil-mirvakili commented Oct 5, 2021 •

Copy link
Copy Markdown
Contributor

The CoDel algorithm has been implemented in the BlueStore to mitigate bufferbloat in the BlueStore backend. The CoDel algorithm limits the number of transactions submitted to BlueStore. The number of transactions is defined using a dual-loop optimization mechanism. The inner (fast) loop minimize the latency by limiting submitted transaction, and the outer (slow) loop control the inner loop to achieve a tradeoff between throughput and latency.

For more information refer to Ceph Code Walkthroughs: CoDel for BlueStore video and presentation.

Signed-off-by: Esmaeil Mirvakili [email protected]

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

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

@esmaeil-mirvakili

Copy link
Copy Markdown
Contributor Author

@athanatos

Comment thread src/os/bluestore/BlueStore.cc Resolved
@athanatos

Copy link
Copy Markdown
Contributor

I'll get into this properly tomorrow.

Comment thread src/os/bluestore/BlueStore.h Resolved
Comment thread src/os/bluestore/BlueStore.h Resolved
Comment thread src/os/bluestore/BlueStore.h Resolved
Comment thread src/os/bluestore/BlueStore.cc Resolved
Comment thread src/os/bluestore/BlueStore.h Resolved
Comment thread src/os/bluestore/BlueStore.h Resolved
Comment thread src/os/bluestore/BlueStore.h Resolved
@athanatos

Copy link
Copy Markdown
Contributor

I think that's sufficient for a first pass. Main feedback is to refactor BlueStoreSlowFastCoDel into a separate file with at least a basic unit test along with general whitespace/formatting fixes.

@esmaeil-mirvakili
esmaeil-mirvakili force-pushed the bluestore-bufferbloat-mitigation branch 3 times, most recently from 38ddedd to 1cfd41f Compare October 26, 2021 11:59
@esmaeil-mirvakili
esmaeil-mirvakili requested a review from a team as a code owner October 26, 2021 11:59
@esmaeil-mirvakili
esmaeil-mirvakili force-pushed the bluestore-bufferbloat-mitigation branch 3 times, most recently from 5fcd0eb to 77e7c7f Compare February 1, 2022 11:48
Comment thread src/os/bluestore/BlueStore.cc Resolved
@athanatos

Copy link
Copy Markdown
Contributor

@esmaeil-mirvakili Have @aclamk 's comments above been addressed?

@esmaeil-mirvakili
esmaeil-mirvakili force-pushed the bluestore-bufferbloat-mitigation branch from 77e7c7f to 8b260f7 Compare March 22, 2022 10:11
…luestore/BlueStoreSlowFastCoDel added

Signed-off-by: Esmaeil Mirvakili <[email protected]>d
@esmaeil-mirvakili
esmaeil-mirvakili force-pushed the bluestore-bufferbloat-mitigation branch from 8b260f7 to ba35015 Compare March 22, 2022 14:23
@athanatos

Copy link
Copy Markdown
Contributor

@esmaeil-mirvakili Is this ready for review?

@esmaeil-mirvakili

Copy link
Copy Markdown
Contributor Author

@athanatos It is ready for review, but something is wrong with the checks. I'll run them again.

@esmaeil-mirvakili

Copy link
Copy Markdown
Contributor Author

jenkins test docs

@esmaeil-mirvakili

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@athanatos

Copy link
Copy Markdown
Contributor

@aclamk Can you take another look? I'm inclined to get this merged sooner rather than later to make testing/iteration easier. It's off by default and (imho) pretty well isolated from the rest of BlueStore, so it should be low risk.

@aclamk aclamk 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 do think now that we should merge this.
I do not think it is ready right now to enable and give to customer,
but it is an important framework that we must have to even be able to improve on actual adaptation algorithm.

@athanatos
athanatos merged commit 78ffeb7 into ceph:master Apr 22, 2022
@neha-ojha

Copy link
Copy Markdown
Member

@athanatos @esmaeil-mirvakili seems like this PR is causing failures like https://jenkins.ceph.com/job/ceph-pull-requests/94227/consoleFull#14584389247725d52c-2930-43cb-b77a-ae0a919c2170. I suspect it is the same failure which was seen in https://trello.com/c/OmPlJ1pq/1513-wip-yuri4-testing-2022-04-22-0932#comment-626317e677cc78785021032d

[ RUN      ] TestSlowFastCoDel.test1
../src/common/Timer.cc: In function 'Context *CommonSafeTimer<ceph::mutex_debug_detail::mutex_debug_impl<false>>::add_event_after(ceph::timespan, Context *) [Mutex = ceph::mutex_debug_detail::mutex_debug_impl<false>]' thread 7f192d101300 time 2022-04-25T15:52:07.507067+0000
../src/common/Timer.cc: 132: FAILED ceph_assert(((lock).is_locked()))
 ceph version Development (no_version) quincy (dev)
 1: (ceph::__ceph_assert_fail(char const*, char const*, int, char const*)+0x1b4) [0x7f192f31fb44]
 2: /home/jenkins-build/build/workspace/ceph-pull-requests/build/lib/libceph-common.so.2(+0x140698f) [0x7f192f31f98f]
 3: (CommonSafeTimer<ceph::mutex_debug_detail::mutex_debug_impl<false> >::add_event_after(std::chrono::duration<unsigned long, std::ratio<1l, 1000000000l> >, Context*)+0x47) [0x7f192f2e63d7]
 4: (BlueStoreSlowFastCoDel::_fast_interval_process()+0x1c5) [0x526765]
 5: (BlueStoreSlowFastCoDel::on_config_changed(ceph::common::CephContext*)+0x285) [0x525fc5]
 6: (BlueStoreSlowFastCoDel::BlueStoreSlowFastCoDel(ceph::common::CephContext*, std::function<void (long)>, std::function<long ()>)+0x22d) [0x525c4d]
 7: (BlueStoreSlowFastCoDelMock::BlueStoreSlowFastCoDelMock(ceph::common::CephContext*, std::function<void (long)>, std::function<long ()>, std::mutex&, std::condition_variable&, long, long, long, double)+0x94) [0x4b7884]
 8: (TestSlowFastCoDel::create_bluestore_slow_fast_codel()+0xd0) [0x4b28c0]
 9: (TestSlowFastCoDel_test1_Test::TestBody()+0x19) [0x4b19a9]
 10: (void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)+0x7b) [0x51d7fb]
 11: (void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)+0x6a) [0x501d0a]
 12: (testing::Test::Run()+0xc3) [0x4dfd73]
 13: (testing::TestInfo::Run()+0xda) [0x4e0aba]
 14: (testing::TestSuite::Run()+0xfb) [0x4e12db]
 15: (testing::internal::UnitTestImpl::RunAllTests()+0x442) [0x4ee9f2]
 16: (bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)+0x7b) [0x52097b]
 17: (bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)+0x6a) [0x5045ca]
 18: (testing::UnitTest::Run()+0xcb) [0x4ee55b]
 19: (RUN_ALL_TESTS()+0x11) [0x4bd691]
 20: main()
 21: __libc_start_main()
 22: _start()

@ljflores ljflores mentioned this pull request Apr 25, 2022
4 of 14 tasks
@ljflores

Copy link
Copy Markdown
Member

@athanatos @esmaeil-mirvakili seems like this PR is causing failures like https://jenkins.ceph.com/job/ceph-pull-requests/94227/consoleFull#14584389247725d52c-2930-43cb-b77a-ae0a919c2170. I suspect it is the same failure which was seen in https://trello.com/c/OmPlJ1pq/1513-wip-yuri4-testing-2022-04-22-0932#comment-626317e677cc78785021032d

[ RUN      ] TestSlowFastCoDel.test1
../src/common/Timer.cc: In function 'Context *CommonSafeTimer<ceph::mutex_debug_detail::mutex_debug_impl<false>>::add_event_after(ceph::timespan, Context *) [Mutex = ceph::mutex_debug_detail::mutex_debug_impl<false>]' thread 7f192d101300 time 2022-04-25T15:52:07.507067+0000
../src/common/Timer.cc: 132: FAILED ceph_assert(((lock).is_locked()))
 ceph version Development (no_version) quincy (dev)
 1: (ceph::__ceph_assert_fail(char const*, char const*, int, char const*)+0x1b4) [0x7f192f31fb44]
 2: /home/jenkins-build/build/workspace/ceph-pull-requests/build/lib/libceph-common.so.2(+0x140698f) [0x7f192f31f98f]
 3: (CommonSafeTimer<ceph::mutex_debug_detail::mutex_debug_impl<false> >::add_event_after(std::chrono::duration<unsigned long, std::ratio<1l, 1000000000l> >, Context*)+0x47) [0x7f192f2e63d7]
 4: (BlueStoreSlowFastCoDel::_fast_interval_process()+0x1c5) [0x526765]
 5: (BlueStoreSlowFastCoDel::on_config_changed(ceph::common::CephContext*)+0x285) [0x525fc5]
 6: (BlueStoreSlowFastCoDel::BlueStoreSlowFastCoDel(ceph::common::CephContext*, std::function<void (long)>, std::function<long ()>)+0x22d) [0x525c4d]
 7: (BlueStoreSlowFastCoDelMock::BlueStoreSlowFastCoDelMock(ceph::common::CephContext*, std::function<void (long)>, std::function<long ()>, std::mutex&, std::condition_variable&, long, long, long, double)+0x94) [0x4b7884]
 8: (TestSlowFastCoDel::create_bluestore_slow_fast_codel()+0xd0) [0x4b28c0]
 9: (TestSlowFastCoDel_test1_Test::TestBody()+0x19) [0x4b19a9]
 10: (void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)+0x7b) [0x51d7fb]
 11: (void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)+0x6a) [0x501d0a]
 12: (testing::Test::Run()+0xc3) [0x4dfd73]
 13: (testing::TestInfo::Run()+0xda) [0x4e0aba]
 14: (testing::TestSuite::Run()+0xfb) [0x4e12db]
 15: (testing::internal::UnitTestImpl::RunAllTests()+0x442) [0x4ee9f2]
 16: (bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)+0x7b) [0x52097b]
 17: (bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)+0x6a) [0x5045ca]
 18: (testing::UnitTest::Run()+0xcb) [0x4ee55b]
 19: (RUN_ALL_TESTS()+0x11) [0x4bd691]
 20: main()
 21: __libc_start_main()
 22: _start()

Tracker: https://tracker.ceph.com/issues/55433

@athanatos

Copy link
Copy Markdown
Contributor

I'm going to go ahead and revert it for now.

@esmaeil-mirvakili

esmaeil-mirvakili commented Apr 25, 2022 •

Copy link
Copy Markdown
Contributor Author

I checked the error and the code, it seems that the problem is only the tests. For implementing the interval-based loops in codel, I used the SafeTimer similar to https://github.com/ceph/ceph/blob/a9cb584d3f07ab30a69883f21b309e8072cc8237/src/test/common/test_lockdep.cc#L19. However the same code is working in other parts of ceph, it can fail when CEPH_DEBUG_MUTEX is defined. When this macro is defined, the timer does some double-checks on mutex lock which will not work with this usage of timer.
One solution is to skip the test if this macro exists for now similar to this test:

#ifndef CEPH_DEBUG_MUTEX

@athanatos

Copy link
Copy Markdown
Contributor

@esmaeil-mirvakili Which double check is it failing?

@esmaeil-mirvakili

Copy link
Copy Markdown
Contributor Author

It is checking that the timer mutex is locked when calling "add_event_after" here.
And in "ceph_mutex.h", if CEPH_DEBUG_MUTEX is not defined it returns true all the time, otherwise it check the lock.

We didn't have any problem with tests before, has something changed in tests or tests after merge are different?

@athanatos

Copy link
Copy Markdown
Contributor

The reason for that check is that failing to lock the timer mutex when calling add_event_after causes elements of the safe_timer api to have race conditions. Are you quite sure that your implementation is actually correct without holding the lock?

@athanatos

Copy link
Copy Markdown
Contributor

@esmaeil-mirvakili Were you able to look into holding the lock while using add_event_after?

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