Skip to content

Commit

Permalink
trace2:gvfs:experiment: read_cache: annotate thread usage in read-cache
Browse files Browse the repository at this point in the history
Add trace2_thread_start() and trace2_thread_exit() events to the worker
threads used to read the index.  This gives per-thread perf data.

These workers were introduced in:
abb4bb8 read-cache: load cache extensions on a worker thread
77ff112 read-cache: load cache entries on worker threads

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
  • Loading branch information
jeffhostetler authored and dscho committed Aug 11, 2023
1 parent e966eaf commit 626d3bd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,17 @@ static void *load_index_extensions(void *_data)
return NULL;
}

static void *load_index_extensions_threadproc(void *_data)
{
void *result;

trace2_thread_start("load_index_extensions");
result = load_index_extensions(_data);
trace2_thread_exit();

return result;
}

/*
* A helper function that will load the specified range of cache entries
* from the memory mapped file and add them to the given index.
Expand Down Expand Up @@ -2132,12 +2143,17 @@ static void *load_cache_entries_thread(void *_data)
struct load_cache_entries_thread_data *p = _data;
int i;

trace2_thread_start("load_cache_entries");

/* iterate across all ieot blocks assigned to this thread */
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
p->offset += p->ieot->entries[i].nr;
}

trace2_thread_exit();

return NULL;
}

Expand Down Expand Up @@ -2305,7 +2321,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
int err;

p.src_offset = extension_offset;
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
if (err)
die(_("unable to create load_index_extensions thread: %s"), strerror(err));

Expand Down

0 comments on commit 626d3bd

Please sign in to comment.