mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] bcache: Revert min_heap migration due to performance regression
@ 2025-06-14 20:23 Kuan-Wei Chiu
  2025-06-14 20:23 ` [PATCH v2 1/3] Revert "bcache: update min_heap_callbacks to use default builtin swap" Kuan-Wei Chiu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Kuan-Wei Chiu @ 2025-06-14 20:23 UTC (permalink / raw)
  To: akpm, colyli, kent.overstreet, robertpang
  Cc: linux-kernel, linux-bcache, jserv, Kuan-Wei Chiu

This patch series reverts the migration of bcache from its original
heap implementation to the generic min_heap library. While the original
change aimed to simplify the code and improve maintainability, it
introduced a severe performance regression in real-world scenarios.

As reported by Robert, systems using bcache now suffer from periodic
latency spikes, with P100 (max) latency increasing from 600 ms to
2.4 seconds every 5 minutes. This degrades bcache's value as a
low-latency caching layer, and leads to frequent timeouts and
application stalls in production environments.

The primary cause of this regression is the behavior of the generic
min_heap implementation's bottom-up sift_down, which performs up to
2 * log2(n) comparisons when many elements are equal. The original
top-down variant used by bcache only required O(1) comparisons in such
cases. The issue was further exacerbated by commit 92a8b224b833
("lib/min_heap: introduce non-inline versions of min heap API
functions"), which introduced non-inlined versions of the min_heap API,
adding function call overhead to a performance-critical hot path.
---

Changes in v2:
- Drop the proposed new min_heap API approach.
- Replace with full reverts of the min_heap-related changes in bcache.

v1: https://lore.kernel.org/lkml/20250610215516.1513296-1-visitorckw@gmail.com

Note: I'm aware that this revert series changes more than 100 lines of
code, which exceeds the typical guideline for stable backports.
However, introducing new generic APIs to fix this regression would also
involve over 100 lines of changes and add new features. In contrast,
reverting to a previously known-good state is a safer and more
straightforward solution in this case.

Kuan-Wei Chiu (3):
  Revert "bcache: update min_heap_callbacks to use default builtin swap"
  Revert "bcache: remove heap-related macros and switch to generic
    min_heap"
  bcache: Remove unnecessary select MIN_HEAP

 drivers/md/bcache/Kconfig     |   1 -
 drivers/md/bcache/alloc.c     |  57 +++++------------
 drivers/md/bcache/bcache.h    |   2 +-
 drivers/md/bcache/bset.c      | 116 +++++++++++++---------------------
 drivers/md/bcache/bset.h      |  40 +++++++-----
 drivers/md/bcache/btree.c     |  69 +++++++++-----------
 drivers/md/bcache/extents.c   |  45 ++++++-------
 drivers/md/bcache/movinggc.c  |  33 +++-------
 drivers/md/bcache/super.c     |   3 +-
 drivers/md/bcache/sysfs.c     |   4 +-
 drivers/md/bcache/util.h      |  67 +++++++++++++++++++-
 drivers/md/bcache/writeback.c |  13 ++--
 12 files changed, 217 insertions(+), 233 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-15  5:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-14 20:23 [PATCH v2 0/3] bcache: Revert min_heap migration due to performance regression Kuan-Wei Chiu
2025-06-14 20:23 ` [PATCH v2 1/3] Revert "bcache: update min_heap_callbacks to use default builtin swap" Kuan-Wei Chiu
2025-06-15  5:51   ` Coly Li
2025-06-14 20:23 ` [PATCH v2 2/3] Revert "bcache: remove heap-related macros and switch to generic min_heap" Kuan-Wei Chiu
2025-06-15  5:51   ` Coly Li
2025-06-14 20:23 ` [PATCH v2 3/3] bcache: Remove unnecessary select MIN_HEAP Kuan-Wei Chiu
2025-06-15  5:52   ` Coly Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®