Skip to content

Commit 4c3e187

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fa7ca5d commit 4c3e187

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cache-tree.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,
494494

495495
void cache_tree_write(struct strbuf *sb, struct cache_tree *root)
496496
{
497+
trace2_region_enter("cache_tree", "write", the_repository);
497498
write_one(sb, root, "", 0);
499+
trace2_region_leave("cache_tree", "write", the_repository);
498500
}
499501

500502
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)
583585

584586
struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
585587
{
588+
struct cache_tree *result;
589+
586590
if (buffer[0])
587591
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;
589598
}
590599

591600
static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *path)

0 commit comments

Comments
 (0)