From 2276d92ca5e2edf7f56de2be39f10d179684fa27 Mon Sep 17 00:00:00 2001 From: liqiang Date: Wed, 29 Dec 2021 11:19:42 +0800 Subject: [PATCH] fix performance issue of pick_a_shard Signed-off-by: liqiang --- ...-mempool-Add-test-for-mempool-shards.patch | 39 +++++++++++++++++++ ...pool-Modify-shard-selection-function.patch | 28 +++++++++++++ ...nly-fail-tests-if-sharding-is-very-b.patch | 27 +++++++++++++ ceph.spec | 9 ++++- 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 0009-common-mempool-Add-test-for-mempool-shards.patch create mode 100644 0010-common-mempool-Modify-shard-selection-function.patch create mode 100644 0011-common-mempool-only-fail-tests-if-sharding-is-very-b.patch diff --git a/0009-common-mempool-Add-test-for-mempool-shards.patch b/0009-common-mempool-Add-test-for-mempool-shards.patch new file mode 100644 index 0000000..456e265 --- /dev/null +++ b/0009-common-mempool-Add-test-for-mempool-shards.patch @@ -0,0 +1,39 @@ +From e4e07de8f36d0d44b341d5784a8bf56192201b95 Mon Sep 17 00:00:00 2001 +From: Adam Kupczyk +Date: Mon, 25 Jan 2021 11:33:28 +0100 +Subject: [PATCH] common/mempool: Add test for mempool shards + +Add test that checks quality of mempool sharing. +It refuses to accept cases when variance is too large. + +Signed-off-by: Adam Kupczyk +--- + src/include/mempool.h | 9 +++++++-- + 1 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/include/mempool.h b/src/include/mempool.h +index 2247cb15bc0..a18f6a502da 100644 +--- a/src/include/mempool.h ++++ b/src/include/mempool.h +@@ -255,11 +255,16 @@ public: + + void adjust_count(ssize_t items, ssize_t bytes); + +- shard_t* pick_a_shard() { ++ static size_t pick_a_shard_int() { + // Dirt cheap, see: +- // http://fossies.org/dox/glibc-2.24/pthread__self_8c_source.html ++ // https://fossies.org/dox/glibc-2.32/pthread__self_8c_source.html + size_t me = (size_t)pthread_self(); + size_t i = (me >> 3) & ((1 << num_shard_bits) - 1); ++ return i; ++ } ++ ++ shard_t* pick_a_shard() { ++ size_t i = pick_a_shard_int(); + return &shard[i]; + } + +-- +2.23.0.windows.1 + diff --git a/0010-common-mempool-Modify-shard-selection-function.patch b/0010-common-mempool-Modify-shard-selection-function.patch new file mode 100644 index 0000000..c207945 --- /dev/null +++ b/0010-common-mempool-Modify-shard-selection-function.patch @@ -0,0 +1,28 @@ +From fccbdc0905e3868666fbb10803bac6b73f687cb1 Mon Sep 17 00:00:00 2001 +From: Adam Kupczyk +Date: Mon, 25 Jan 2021 11:45:06 +0100 +Subject: [PATCH] common/mempool: Modify shard selection function + +Modify shard selection function, so no longer all threads use the same shard 0. + +Signed-off-by: Adam Kupczyk +--- + src/include/mempool.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/include/mempool.h b/src/include/mempool.h +index a18f6a502da..c03aa175cfa 100644 +--- a/src/include/mempool.h ++++ b/src/include/mempool.h +@@ -259,7 +259,7 @@ public: + // Dirt cheap, see: + // https://fossies.org/dox/glibc-2.32/pthread__self_8c_source.html + size_t me = (size_t)pthread_self(); +- size_t i = (me >> 3) & ((1 << num_shard_bits) - 1); ++ size_t i = (me >> 12) & ((1 << num_shard_bits) - 1); + return i; + } + +-- +2.23.0.windows.1 + diff --git a/0011-common-mempool-only-fail-tests-if-sharding-is-very-b.patch b/0011-common-mempool-only-fail-tests-if-sharding-is-very-b.patch new file mode 100644 index 0000000..4284e03 --- /dev/null +++ b/0011-common-mempool-only-fail-tests-if-sharding-is-very-b.patch @@ -0,0 +1,27 @@ +From db79769d6d557acc021a434ff285db2d69458d0a Mon Sep 17 00:00:00 2001 +From: singuliere +Date: Wed, 17 Mar 2021 07:35:04 +0100 +Subject: [PATCH] common/mempool: only fail tests if sharding is very bad + +Fixes: https://tracker.ceph.com/issues/49781 +Signed-off-by: singuliere +--- + src/include/mempool.h | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/src/include/mempool.h b/src/include/mempool.h +index c03aa175cfa..fe84f3b8f09 100644 +--- a/src/include/mempool.h ++++ b/src/include/mempool.h +@@ -259,7 +259,7 @@ public: + // Dirt cheap, see: + // https://fossies.org/dox/glibc-2.32/pthread__self_8c_source.html + size_t me = (size_t)pthread_self(); +- size_t i = (me >> 12) & ((1 << num_shard_bits) - 1); ++ size_t i = (me >> CEPH_PAGE_SHIFT) & ((1 << num_shard_bits) - 1); + return i; + } + +-- +2.23.0.windows.1 + diff --git a/ceph.spec b/ceph.spec index 64bbc90..013065f 100644 --- a/ceph.spec +++ b/ceph.spec @@ -110,7 +110,7 @@ ################################################################################# Name: ceph Version: 14.2.15 -Release: 7%{?dist} +Release: 8%{?dist} %if 0%{?fedora} || 0%{?rhel} || 0%{?openEuler} Epoch: 2 %endif @@ -138,6 +138,9 @@ Patch5: 0005-CVE-2020-27781-5.patch Patch6: 0006-CVE-2021-3524-1.patch Patch7: 0007-fix-build-error-PTHREAD_STACK_MIN.patch Patch9: 0008-common-crc32c_aarch64-fix-crc32c-unittest-failed-on-.patch +Patch10: 0009-common-mempool-Add-test-for-mempool-shards.patch +Patch11: 0010-common-mempool-Modify-shard-selection-function.patch +Patch12: 0011-common-mempool-only-fail-tests-if-sharding-is-very-b.patch %if 0%{?suse_version} # _insert_obs_source_lines_here @@ -2045,6 +2048,10 @@ exit 0 %changelog +* Wed Dec 29 2021 Li Qiang - 1:14.2.15-8 +- Synchronize the performance optimization of the pick_a_shard +- function in the upstream community. + * Fri Nov 5 2021 Dai Zhiwei - 1:14.2.15-7 - fix aarch64 crc32c unittest error -- Gitee