* Potential heapify performance issue in dm-vdo
@ 2025-05-21 15:04 Kuan-Wei Chiu
2025-05-21 18:57 ` Matthew Sakai
0 siblings, 1 reply; 3+ messages in thread
From: Kuan-Wei Chiu @ 2025-05-21 15:04 UTC (permalink / raw)
To: Matthew Sakai; +Cc: dm-devel, linux-kernel, jserv
Hi Matthew,
Recently noticed that the current heapify method in min_heap.h may
degrade performance when the heap contains many compare-equal elements,
compared to the previous version.
In detail, the new heapify reduces the number of comparisons by about
50% when all elements are distinct. However, when all elements are
equal, the comparison count can degrade from O(1) to O(log n).
I don't have enough domain knowledge of dm-vdo, so I'd like to ask
whether it uses heaps with many compare-equal elements. If so, I'll
work on fixing the issue.
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Potential heapify performance issue in dm-vdo
2025-05-21 15:04 Potential heapify performance issue in dm-vdo Kuan-Wei Chiu
@ 2025-05-21 18:57 ` Matthew Sakai
2025-05-22 7:22 ` Kuan-Wei Chiu
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Sakai @ 2025-05-21 18:57 UTC (permalink / raw)
To: Kuan-Wei Chiu; +Cc: dm-devel, linux-kernel, jserv
On 5/21/25 11:04 AM, Kuan-Wei Chiu wrote:
> Hi Matthew,
>
> Recently noticed that the current heapify method in min_heap.h may
> degrade performance when the heap contains many compare-equal elements,
> compared to the previous version.
>
> In detail, the new heapify reduces the number of comparisons by about
> 50% when all elements are distinct. However, when all elements are
> equal, the comparison count can degrade from O(1) to O(log n).
>
> I don't have enough domain knowledge of dm-vdo, so I'd like to ask
> whether it uses heaps with many compare-equal elements. If so, I'll
> work on fixing the issue.
>
> Regards,
> Kuan-Wei
Hi Kuan-Wei,
dm-vdo uses heapify for two different operations, but in both cases we
define heap elements that can never be equal to each other. So I think
this is not an issue for dm-vdo. (We have not noticed any issues with
this in our regular testing, either.)
Matt
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Potential heapify performance issue in dm-vdo
2025-05-21 18:57 ` Matthew Sakai
@ 2025-05-22 7:22 ` Kuan-Wei Chiu
0 siblings, 0 replies; 3+ messages in thread
From: Kuan-Wei Chiu @ 2025-05-22 7:22 UTC (permalink / raw)
To: Matthew Sakai; +Cc: dm-devel, linux-kernel, jserv
On Wed, May 21, 2025 at 02:57:26PM -0400, Matthew Sakai wrote:
>
>
> On 5/21/25 11:04 AM, Kuan-Wei Chiu wrote:
> > Hi Matthew,
> >
> > Recently noticed that the current heapify method in min_heap.h may
> > degrade performance when the heap contains many compare-equal elements,
> > compared to the previous version.
> >
> > In detail, the new heapify reduces the number of comparisons by about
> > 50% when all elements are distinct. However, when all elements are
> > equal, the comparison count can degrade from O(1) to O(log n).
> >
> > I don't have enough domain knowledge of dm-vdo, so I'd like to ask
> > whether it uses heaps with many compare-equal elements. If so, I'll
> > work on fixing the issue.
> >
> > Regards,
> > Kuan-Wei
>
> Hi Kuan-Wei,
>
> dm-vdo uses heapify for two different operations, but in both cases we
> define heap elements that can never be equal to each other. So I think this
> is not an issue for dm-vdo. (We have not noticed any issues with this in our
> regular testing, either.)
>
Thanks for confirming that dm-vdo won't encounter this issue.
We observed a regression in bcache caused by this behavior, and Coly
was concerned that dm-vdo might be affected in a similar way.
Fortunately, that doesn't seem to be the case.
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-22 7:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21 15:04 Potential heapify performance issue in dm-vdo Kuan-Wei Chiu
2025-05-21 18:57 ` Matthew Sakai
2025-05-22 7:22 ` Kuan-Wei Chiu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.