Commit dc3b63dc authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Add time stats for btree updates

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 1a470560
...@@ -290,10 +290,11 @@ do { \ ...@@ -290,10 +290,11 @@ do { \
#define BCH_TIME_STATS() \ #define BCH_TIME_STATS() \
x(btree_node_mem_alloc) \ x(btree_node_mem_alloc) \
x(btree_node_split) \
x(btree_node_sort) \
x(btree_node_read) \
x(btree_gc) \ x(btree_gc) \
x(btree_split) \ x(btree_update) \
x(btree_sort) \
x(btree_read) \
x(btree_lock_contended_read) \ x(btree_lock_contended_read) \
x(btree_lock_contended_intent) \ x(btree_lock_contended_intent) \
x(btree_lock_contended_write) \ x(btree_lock_contended_write) \
......
...@@ -327,7 +327,7 @@ static void btree_node_sort(struct bch_fs *c, struct btree *b, ...@@ -327,7 +327,7 @@ static void btree_node_sort(struct bch_fs *c, struct btree *b,
BUG_ON(vstruct_end(&out->keys) > (void *) out + (PAGE_SIZE << order)); BUG_ON(vstruct_end(&out->keys) > (void *) out + (PAGE_SIZE << order));
if (sorting_entire_node) if (sorting_entire_node)
bch2_time_stats_update(&c->times[BCH_TIME_btree_sort], bch2_time_stats_update(&c->times[BCH_TIME_btree_node_sort],
start_time); start_time);
/* Make sure we preserve bset journal_seq: */ /* Make sure we preserve bset journal_seq: */
...@@ -403,7 +403,8 @@ void bch2_btree_sort_into(struct bch_fs *c, ...@@ -403,7 +403,8 @@ void bch2_btree_sort_into(struct bch_fs *c,
&dst->format, &dst->format,
true); true);
bch2_time_stats_update(&c->times[BCH_TIME_btree_sort], start_time); bch2_time_stats_update(&c->times[BCH_TIME_btree_node_sort],
start_time);
set_btree_bset_end(dst, dst->set); set_btree_bset_end(dst, dst->set);
...@@ -988,7 +989,8 @@ static void btree_node_read_work(struct work_struct *work) ...@@ -988,7 +989,8 @@ static void btree_node_read_work(struct work_struct *work)
} }
} }
bch2_time_stats_update(&c->times[BCH_TIME_btree_read], rb->start_time); bch2_time_stats_update(&c->times[BCH_TIME_btree_node_read],
rb->start_time);
bio_put(&rb->bio); bio_put(&rb->bio);
clear_btree_node_read_in_flight(b); clear_btree_node_read_in_flight(b);
wake_up_bit(&b->flags, BTREE_NODE_read_in_flight); wake_up_bit(&b->flags, BTREE_NODE_read_in_flight);
......
...@@ -274,6 +274,7 @@ struct btree_insert_entry { ...@@ -274,6 +274,7 @@ struct btree_insert_entry {
struct btree_trans { struct btree_trans {
struct bch_fs *c; struct bch_fs *c;
size_t nr_restarts; size_t nr_restarts;
u64 commit_start;
u64 iters_live; u64 iters_live;
u64 iters_linked; u64 iters_linked;
......
...@@ -1440,7 +1440,8 @@ static void btree_split(struct btree_update *as, struct btree *b, ...@@ -1440,7 +1440,8 @@ static void btree_split(struct btree_update *as, struct btree *b,
bch2_btree_iter_verify_locks(iter); bch2_btree_iter_verify_locks(iter);
bch2_time_stats_update(&c->times[BCH_TIME_btree_split], start_time); bch2_time_stats_update(&c->times[BCH_TIME_btree_node_split],
start_time);
} }
static void static void
......
...@@ -824,10 +824,10 @@ int bch2_trans_commit(struct btree_trans *trans, ...@@ -824,10 +824,10 @@ int bch2_trans_commit(struct btree_trans *trans,
{ {
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
struct btree_insert_entry *i; struct btree_insert_entry *i;
int ret; int ret = 0;
if (!trans->nr_updates) if (!trans->nr_updates)
return 0; goto out;
/* for the sake of sanity: */ /* for the sake of sanity: */
BUG_ON(trans->nr_updates > 1 && !(flags & BTREE_INSERT_ATOMIC)); BUG_ON(trans->nr_updates > 1 && !(flags & BTREE_INSERT_ATOMIC));
...@@ -850,6 +850,9 @@ int bch2_trans_commit(struct btree_trans *trans, ...@@ -850,6 +850,9 @@ int bch2_trans_commit(struct btree_trans *trans,
!percpu_ref_tryget(&c->writes))) !percpu_ref_tryget(&c->writes)))
return -EROFS; return -EROFS;
if (!trans->commit_start)
trans->commit_start = local_clock();
ret = bch2_trans_journal_preres_get(trans); ret = bch2_trans_journal_preres_get(trans);
if (ret) if (ret)
goto err; goto err;
...@@ -860,6 +863,12 @@ int bch2_trans_commit(struct btree_trans *trans, ...@@ -860,6 +863,12 @@ int bch2_trans_commit(struct btree_trans *trans,
if (unlikely(!(trans->flags & BTREE_INSERT_NOCHECK_RW))) if (unlikely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
percpu_ref_put(&c->writes); percpu_ref_put(&c->writes);
out:
if (!ret && trans->commit_start) {
bch2_time_stats_update(&c->times[BCH_TIME_btree_update],
trans->commit_start);
trans->commit_start = 0;
}
trans->nr_updates = 0; trans->nr_updates = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment