Skip to content

Commit 42fee7a

Browse files
jeffhostetlergitster
authored andcommitted
trace2:data: add trace2 instrumentation to index read/write
Add trace2 events to measure reading and writing the index. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6206286 commit 42fee7a

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

read-cache.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2220,6 +2220,16 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22202220
load_index_extensions(&p);
22212221
}
22222222
munmap((void *)mmap, mmap_size);
2223+
2224+
/*
2225+
* TODO trace2: replace "the_repository" with the actual repo instance
2226+
* that is associated with the given "istate".
2227+
*/
2228+
trace2_data_intmax("index", the_repository, "read/version",
2229+
istate->version);
2230+
trace2_data_intmax("index", the_repository, "read/cache_nr",
2231+
istate->cache_nr);
2232+
22232233
return istate->cache_nr;
22242234

22252235
unmap:
@@ -2251,9 +2261,17 @@ int read_index_from(struct index_state *istate, const char *path,
22512261
if (istate->initialized)
22522262
return istate->cache_nr;
22532263

2264+
/*
2265+
* TODO trace2: replace "the_repository" with the actual repo instance
2266+
* that is associated with the given "istate".
2267+
*/
2268+
trace2_region_enter_printf("index", "do_read_index", the_repository,
2269+
"%s", path);
22542270
trace_performance_enter();
22552271
ret = do_read_index(istate, path, 0);
22562272
trace_performance_leave("read cache %s", path);
2273+
trace2_region_leave_printf("index", "do_read_index", the_repository,
2274+
"%s", path);
22572275

22582276
split_index = istate->split_index;
22592277
if (!split_index || is_null_oid(&split_index->base_oid)) {
@@ -2269,7 +2287,11 @@ int read_index_from(struct index_state *istate, const char *path,
22692287

22702288
base_oid_hex = oid_to_hex(&split_index->base_oid);
22712289
base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
2290+
trace2_region_enter_printf("index", "shared/do_read_index",
2291+
the_repository, "%s", base_path);
22722292
ret = do_read_index(split_index->base, base_path, 1);
2293+
trace2_region_leave_printf("index", "shared/do_read_index",
2294+
the_repository, "%s", base_path);
22732295
if (!oideq(&split_index->base_oid, &split_index->base->oid))
22742296
die(_("broken index, expect %s in %s, got %s"),
22752297
base_oid_hex, base_path,
@@ -2976,6 +2998,16 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
29762998
istate->timestamp.sec = (unsigned int)st.st_mtime;
29772999
istate->timestamp.nsec = ST_MTIME_NSEC(st);
29783000
trace_performance_since(start, "write index, changed mask = %x", istate->cache_changed);
3001+
3002+
/*
3003+
* TODO trace2: replace "the_repository" with the actual repo instance
3004+
* that is associated with the given "istate".
3005+
*/
3006+
trace2_data_intmax("index", the_repository, "write/version",
3007+
istate->version);
3008+
trace2_data_intmax("index", the_repository, "write/cache_nr",
3009+
istate->cache_nr);
3010+
29793011
return 0;
29803012
}
29813013

@@ -2995,7 +3027,18 @@ static int commit_locked_index(struct lock_file *lk)
29953027
static int do_write_locked_index(struct index_state *istate, struct lock_file *lock,
29963028
unsigned flags)
29973029
{
2998-
int ret = do_write_index(istate, lock->tempfile, 0);
3030+
int ret;
3031+
3032+
/*
3033+
* TODO trace2: replace "the_repository" with the actual repo instance
3034+
* that is associated with the given "istate".
3035+
*/
3036+
trace2_region_enter_printf("index", "do_write_index", the_repository,
3037+
"%s", lock->tempfile->filename.buf);
3038+
ret = do_write_index(istate, lock->tempfile, 0);
3039+
trace2_region_leave_printf("index", "do_write_index", the_repository,
3040+
"%s", lock->tempfile->filename.buf);
3041+
29993042
if (ret)
30003043
return ret;
30013044
if (flags & COMMIT_LOCK)
@@ -3080,7 +3123,13 @@ static int write_shared_index(struct index_state *istate,
30803123
int ret;
30813124

30823125
move_cache_to_base_index(istate);
3126+
3127+
trace2_region_enter_printf("index", "shared/do_write_index",
3128+
the_repository, "%s", (*temp)->filename.buf);
30833129
ret = do_write_index(si->base, *temp, 1);
3130+
trace2_region_enter_printf("index", "shared/do_write_index",
3131+
the_repository, "%s", (*temp)->filename.buf);
3132+
30843133
if (ret)
30853134
return ret;
30863135
ret = adjust_shared_perm(get_tempfile_path(*temp));

0 commit comments

Comments
 (0)