Skip to content

Commit

Permalink
Merge pull request #158 from jeffhostetler/jh-vfs-222-read-cache-thre…
Browse files Browse the repository at this point in the history
…ading

Trace2:Gvfs:Experiment: read-cache: trace threading and cache-tree extension
  • Loading branch information
jeffhostetler authored Jul 10, 2019
2 parents ea22768 + 4e28740 commit 87a148b
Showing 1 changed file with 24 additions and 1 deletion.
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

0 comments on commit 87a148b

Please sign in to comment.