]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bcachefs: Eytzinger accumulation for accounting keys
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 27 Dec 2023 16:33:21 +0000 (11:33 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Jul 2024 23:00:14 +0000 (19:00 -0400)
commitb9efa9673e1d3fee530b582dbde1827d336513a8
treef4b8f5c122dea59a56d5ea6ef9cb366330c41f79
parent20ac515a9cc73d48be1462d2a04cda75215a1867
bcachefs: Eytzinger accumulation for accounting keys

The btree write buffer takes as input keys from the journal, sorts them,
deduplicates them, and flushes them back to the btree in sorted order.

The disk space accounting rewrite is moving accounting to normal btree
keys, with update (in this case deltas) accumulated in the write buffer
and then flushed to the btree; but this is going to increase the number
of keys handled by the write buffer by perhaps as much as a factor of
3x-5x.

The overhead from copying around and sorting this many keys would cause
a significant performance regression, but: there is huge locality in
updates to accounting keys that we can take advantage of.

Instead of appending accounting keys to the list of keys to be sorted,
this patch adds an eytzinger search tree of recently seen accounting
keys. We look up the accounting key in the eytzinger search tree and
apply the delta directly, adding it if it doesn't exist, and
periodically prune the eytzinger tree of unused entries.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_write_buffer.c
fs/bcachefs/btree_write_buffer.h
fs/bcachefs/btree_write_buffer_types.h
fs/bcachefs/journal_io.c