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 { \
#define BCH_TIME_STATS() \
x(btree_node_mem_alloc) \
x(btree_node_split) \
x(btree_node_sort) \
x(btree_node_read) \
x(btree_gc) \
x(btree_split) \
x(btree_sort) \
x(btree_read) \
x(btree_update) \
x(btree_lock_contended_read) \
x(btree_lock_contended_intent) \
x(btree_lock_contended_write) \
......
......@@ -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));
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);
/* Make sure we preserve bset journal_seq: */
......@@ -403,7 +403,8 @@ void bch2_btree_sort_into(struct bch_fs *c,
&dst->format,
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);
......@@ -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);
clear_btree_node_read_in_flight(b);
wake_up_bit(&b->flags, BTREE_NODE_read_in_flight);
......
......@@ -274,6 +274,7 @@ struct btree_insert_entry {
struct btree_trans {
struct bch_fs *c;
size_t nr_restarts;
u64 commit_start;
u64 iters_live;
u64 iters_linked;
......
......@@ -1440,7 +1440,8 @@ static void btree_split(struct btree_update *as, struct btree *b,
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
......
......@@ -824,10 +824,10 @@ int bch2_trans_commit(struct btree_trans *trans,
{
struct bch_fs *c = trans->c;
struct btree_insert_entry *i;
int ret;
int ret = 0;
if (!trans->nr_updates)
return 0;
goto out;
/* for the sake of sanity: */
BUG_ON(trans->nr_updates > 1 && !(flags & BTREE_INSERT_ATOMIC));
......@@ -850,6 +850,9 @@ int bch2_trans_commit(struct btree_trans *trans,
!percpu_ref_tryget(&c->writes)))
return -EROFS;
if (!trans->commit_start)
trans->commit_start = local_clock();
ret = bch2_trans_journal_preres_get(trans);
if (ret)
goto err;
......@@ -860,6 +863,12 @@ int bch2_trans_commit(struct btree_trans *trans,
if (unlikely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
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;
......
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