dm-transaction-manager: use red-black trees instead of linear lists
authorMikulas Patocka <mpatocka@redhat.com>
Wed, 15 Jan 2025 17:33:30 +0000 (18:33 +0100)
committerMikulas Patocka <mpatocka@redhat.com>
Fri, 17 Jan 2025 21:05:40 +0000 (22:05 +0100)
commita38425935f7886cef5fe04c796f36715e9d0ef3f
tree7634ad090a6986457de6143960c764d6293f192c
parentcd6521d03f6a722f18fc027f0d289c39d164dc4f
dm-transaction-manager: use red-black trees instead of linear lists

There was reported performance degradation when the shadow map contained
too many entries [1]. The shadow map uses 256-bucket hash with linear
lists - when there are too many entries, it has quadratic complexity.

Meir Elisha proposed to add a module parameter that could configure the
size of the hash array - however, this is not ideal because users don't
know that they should increase the parameter when they get bad
performance.

This commit replaces the linear lists with rb-trees (so that there's a
hash of rb-trees), they have logarithmic complexity, so it solves the
performance degradation.

Link: https://patchwork.kernel.org/project/dm-devel/patch/20241014134944.1264991-1-meir.elisha@volumez.com/
Reported-by: Meir Elisha <meir.elisha@volumez.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/persistent-data/dm-transaction-manager.c