From: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx> Teach git to generate a structured logging detail-event for lazy_init_name_hash(). This is marked as an "index" category event and includes time and size data for the hashmaps. Signed-off-by: Jeff Hostetler <jeffhost@xxxxxxxxxxxxx> --- name-hash.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/name-hash.c b/name-hash.c index 1638498..939b26a 100644 --- a/name-hash.c +++ b/name-hash.c @@ -7,6 +7,8 @@ */ #define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "json-writer.h" +#include "structured-logging.h" struct dir_entry { struct hashmap_entry ent; @@ -603,6 +605,30 @@ static void lazy_init_name_hash(struct index_state *istate) istate->name_hash_initialized = 1; trace_performance_since(start, "initialize name hash"); + + if (slog_want_detail_event("index")) { + struct json_writer jw = JSON_WRITER_INIT; + uint64_t now_ns = getnanotime(); + uint64_t elapsed_us = (now_ns - start) / 1000; + + jw_object_begin(&jw, slog_is_pretty()); + { + jw_object_intmax(&jw, "cache_nr", istate->cache_nr); + jw_object_intmax(&jw, "elapsed_us", elapsed_us); + jw_object_intmax(&jw, "dir_count", + hashmap_get_size(&istate->dir_hash)); + jw_object_intmax(&jw, "dir_tablesize", + istate->dir_hash.tablesize); + jw_object_intmax(&jw, "name_count", + hashmap_get_size(&istate->name_hash)); + jw_object_intmax(&jw, "name_tablesize", + istate->name_hash.tablesize); + } + jw_end(&jw); + + slog_emit_detail_event("index", "lazy_init_name_hash", &jw); + jw_release(&jw); + } } /* -- 2.9.3