summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_write_buffer_types.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-12-27 11:33:21 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-06-23 12:57:15 -0400
commit80912778d816d762095d02f20768bb58513422b2 (patch)
tree5dca497a799946a1666a47cdc952629cb4bbbdc1 /fs/bcachefs/btree_write_buffer_types.h
parent9791390e9379aafad194994d5e1dbdb1ce201ef4 (diff)
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>
Diffstat (limited to 'fs/bcachefs/btree_write_buffer_types.h')
-rw-r--r--fs/bcachefs/btree_write_buffer_types.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_write_buffer_types.h b/fs/bcachefs/btree_write_buffer_types.h
index 9b9433de9c36..e9e76e20f43b 100644
--- a/fs/bcachefs/btree_write_buffer_types.h
+++ b/fs/bcachefs/btree_write_buffer_types.h
@@ -52,6 +52,8 @@ struct btree_write_buffer {
struct btree_write_buffer_keys inc;
struct btree_write_buffer_keys flushing;
struct work_struct flush_work;
+
+ DARRAY(struct btree_write_buffered_key) accounting;
};
#endif /* _BCACHEFS_BTREE_WRITE_BUFFER_TYPES_H */