Skip to content

Trace2:Gvfs:Experiment: read-cache: trace threading and cache-tree extension #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,10 @@ static int read_index_extension(struct index_state *istate,
{
switch (CACHE_EXT(ext)) {
case CACHE_EXT_TREE:
trace2_region_enter("index", "read/extension/cache_tree", NULL);
istate->cache_tree = cache_tree_read(data, sz);
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
trace2_region_leave("index", "read/extension/cache_tree", NULL);
break;
case CACHE_EXT_RESOLVE_UNDO:
istate->resolve_undo = resolve_undo_read(data, sz);
Expand Down Expand Up @@ -1957,6 +1960,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 @@ -2032,12 +2046,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 @@ -2187,7 +2206,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 Expand Up @@ -2935,9 +2954,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
struct strbuf sb = STRBUF_INIT;

trace2_region_enter("index", "write/extension/cache_tree", NULL);
cache_tree_write(&sb, istate->cache_tree);
err = write_index_ext_header(&c, &eoie_c, newfd, CACHE_EXT_TREE, sb.len) < 0
|| ce_write(&c, newfd, sb.buf, sb.len) < 0;
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
trace2_region_leave("index", "write/extension/cache_tree", NULL);

strbuf_release(&sb);
if (err)
return -1;
Expand Down