cache-tree: trace regions for I/O

As we write or read the cache tree index extension, it can be good to isolate how much of the file I/O time is spent constructing this in-memory tree from the existing index or writing it out again to the new index file. Use trace2 regions to indicate that we are spending time on this operation. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Jan 4, 2021 at 03:09 UTC 4c3e18723cc4ba7a74e067e85831530285f4dd35
1 file changed +10 -1
cache-tree.c
+10 -1
@@ -494,7 +494,9 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,
494
495 void cache_tree_write(struct strbuf *sb, struct cache_tree *root)
496 {
497 + trace2_region_enter("cache_tree", "write", the_repository);
498 write_one(sb, root, "", 0);
499 + trace2_region_leave("cache_tree", "write", the_repository);
500 }
501
502 static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
@@ -583,9 +585,16 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
585
586 struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
587 {
588 + struct cache_tree *result;
589 +
590 if (buffer[0])
591 return NULL; /* not the whole tree */
588 - return read_one(&buffer, &size);
592 +
593 + trace2_region_enter("cache_tree", "read", the_repository);
594 + result = read_one(&buffer, &size);
595 + trace2_region_leave("cache_tree", "read", the_repository);
596 +
597 + return result;
598 }
599
600 static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *path)