path: root/name-hash.c
diff options
authorNguyễn Thái Ngọc Duy <>2018-08-18 14:41:22 (GMT)
committerJunio C Hamano <>2018-08-18 16:47:46 (GMT)
commitc46c406ae1ee30f64a13083edfa5683d2685fd61 (patch)
tree5e632617017349a94b5357aaad6bf2a52c64032a /name-hash.c
parentfa03cdc39b951d1cfbfd690fe6f3ac6c57ab6a44 (diff)
trace.h: support nested performance tracing
Performance measurements are listed right now as a flat list, which is fine when we measure big blocks. But when we start adding more and more measurements, some of them could be just part of a bigger measurement and a flat list gives a wrong impression that they are executed at the same level instead of nested. Add trace_performance_enter() and trace_performance_leave() to allow indent these nested measurements. For now it does not help much because the only nested thing is (lazy) name hash initialization (e.g. called in diff-index from "git status"). This will help more because I'm going to add some more tracing that's actually nested. Signed-off-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'name-hash.c')
1 files changed, 2 insertions, 2 deletions
diff --git a/name-hash.c b/name-hash.c
index 1638498..1fcda73 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -578,10 +578,10 @@ static void threaded_lazy_init_name_hash(
static void lazy_init_name_hash(struct index_state *istate)
- uint64_t start = getnanotime();
if (istate->name_hash_initialized)
+ trace_performance_enter();
hashmap_init(&istate->name_hash, cache_entry_cmp, NULL, istate->cache_nr);
hashmap_init(&istate->dir_hash, dir_entry_cmp, NULL, istate->cache_nr);
@@ -602,7 +602,7 @@ static void lazy_init_name_hash(struct index_state *istate)
istate->name_hash_initialized = 1;
- trace_performance_since(start, "initialize name hash");
+ trace_performance_leave("initialize name hash");