Skip to content

Commit

Permalink
Merge branch 'vfs-trace2'
Browse files Browse the repository at this point in the history
Includes gvfs-specific commits from PR#115
  • Loading branch information
jeffhostetler authored and dscho committed Aug 17, 2019
2 parents 036b953 + c12bd0e commit d762feb
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 17 deletions.
11 changes: 10 additions & 1 deletion builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "unpack-trees.h"
#include "wt-status.h"
#include "xdiff-interface.h"
#include "packfile.h"

static const char * const checkout_usage[] = {
N_("git checkout [<options>] <branch>"),
Expand Down Expand Up @@ -905,8 +906,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
remove_branch_state(the_repository, !opts->quiet);
strbuf_release(&msg);
if (!opts->quiet &&
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
unsigned long nr_unpack_entry_at_start;

trace2_region_enter("tracking", "report_tracking", the_repository);
nr_unpack_entry_at_start = get_nr_unpack_entry();
report_tracking(new_branch_info);
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
trace2_region_leave("tracking", "report_tracking", the_repository);
}
}

static int add_pending_uninteresting_ref(const char *refname,
Expand Down
19 changes: 18 additions & 1 deletion builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
static int do_serialize = 0;
static char *serialize_path = NULL;

static int reject_implicit = 0;
static int do_implicit_deserialize = 0;
static int do_explicit_deserialize = 0;
static char *deserialize_path = NULL;
Expand Down Expand Up @@ -211,7 +212,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
deserialize_path = xstrdup(arg);
}
if (deserialize_path && *deserialize_path
&& (access(deserialize_path, R_OK) != 0))
&& (wt_status_deserialize_access(deserialize_path, R_OK) != 0))
die("cannot find serialization file '%s'",
deserialize_path);

Expand Down Expand Up @@ -1417,6 +1418,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
if (v && *v && access(v, R_OK) == 0) {
do_implicit_deserialize = 1;
deserialize_path = xstrdup(v);
} else {
reject_implicit = 1;
}
return 0;
}
Expand Down Expand Up @@ -1573,6 +1576,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
(do_implicit_deserialize || do_explicit_deserialize));
if (try_deserialize)
goto skip_init;
/*
* If we implicitly received a status cache pathname from the config
* and the file does not exist, we silently reject it and do the normal
* status "collect". Fake up some trace2 messages to reflect this and
* assist post-processors know this case is different.
*/
if (!do_serialize && reject_implicit) {
trace2_cmd_mode("implicit-deserialize");
trace2_data_string("status", the_repository, "deserialize/reject",
"status-cache/access");
}

enable_fscache(0);
if (status_format != STATUS_FORMAT_PORCELAIN &&
Expand Down Expand Up @@ -1616,6 +1630,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
if (s.relative_paths)
s.prefix = prefix;

trace2_cmd_mode("deserialize");
result = wt_status_deserialize(&s, deserialize_path, dw);
if (result == DESERIALIZE_OK)
return 0;
Expand All @@ -1633,6 +1648,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
fd = -1;
}

trace2_cmd_mode("collect");
wt_status_collect(&s);

if (0 <= fd)
Expand All @@ -1647,6 +1663,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
if (fd_serialize < 0)
die_errno(_("could not serialize to '%s'"),
serialize_path);
trace2_cmd_mode("serialize");
wt_status_serialize_v1(fd_serialize, &s);
close(fd_serialize);
}
Expand Down
19 changes: 17 additions & 2 deletions cache-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,31 @@ static void discard_unused_subtrees(struct cache_tree *it)
}
}

int cache_tree_fully_valid(struct cache_tree *it)
static int cache_tree_fully_valid_1(struct cache_tree *it)
{
int i;
if (!it)
return 0;
if (it->entry_count < 0 || !has_object_file(&it->oid))
return 0;
for (i = 0; i < it->subtree_nr; i++) {
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
if (!cache_tree_fully_valid_1(it->down[i]->cache_tree))
return 0;
}
return 1;
}

int cache_tree_fully_valid(struct cache_tree *it)
{
int result;

trace2_region_enter("cache_tree", "fully_valid", NULL);
result = cache_tree_fully_valid_1(it);
trace2_region_leave("cache_tree", "fully_valid", NULL);

return result;
}

static int update_one(struct cache_tree *it,
struct cache_entry **cache,
int entries,
Expand Down Expand Up @@ -715,10 +726,14 @@ void prime_cache_tree(struct repository *r,
struct index_state *istate,
struct tree *tree)
{
trace2_region_enter("cache_tree", "prime_cache_tree", r);

cache_tree_free(&istate->cache_tree);
istate->cache_tree = cache_tree();
prime_cache_tree_rec(r, istate->cache_tree, tree);
istate->cache_changed |= CACHE_TREE_CHANGED;

trace2_region_leave("cache_tree", "prime_cache_tree", r);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3226,6 +3226,8 @@ int wmain(int argc, const wchar_t **wargv)

SetConsoleCtrlHandler(handle_ctrl_c, TRUE);

trace2_initialize_clock();

maybe_redirect_std_handles();
adjust_symlink_flags();
fsync_object_files = 1;
Expand Down
9 changes: 9 additions & 0 deletions packfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,13 @@ static void *read_object(struct repository *r,
return content;
}

static unsigned long g_nr_unpack_entry;

unsigned long get_nr_unpack_entry(void)
{
return g_nr_unpack_entry;
}

void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
enum object_type *final_type, unsigned long *final_size)
{
Expand All @@ -1659,6 +1666,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
int base_from_cache = 0;

g_nr_unpack_entry++;

write_pack_access_log(p, obj_offset);

/* PHASE 1: drill down to the innermost base object */
Expand Down
5 changes: 5 additions & 0 deletions packfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,9 @@ int is_promisor_object(const struct object_id *oid);
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
size_t idx_size, struct packed_git *p);

/*
* Return the number of objects fetched from a packfile.
*/
unsigned long get_nr_unpack_entry(void);

#endif
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
9 changes: 9 additions & 0 deletions remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
char *base;
int upstream_is_gone = 0;

trace2_region_enter("tracking", "stat_tracking_info", NULL);
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
if (abf == AHEAD_BEHIND_FULL) {
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
}
trace2_region_leave("tracking", "stat_tracking_info", NULL);

if (sti < 0) {
if (!full_base)
return 0;
Expand Down
15 changes: 12 additions & 3 deletions sha1-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,8 @@ static int read_object_process(const struct object_id *oid)

start = getnanotime();

trace2_region_enter("subprocess", "read_object", the_repository);

if (!subprocess_map_initialized) {
subprocess_map_initialized = 1;
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
Expand All @@ -920,13 +922,16 @@ static int read_object_process(const struct object_id *oid)
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
start_read_object_fn)) {
free(entry);
return -1;
err = -1;
goto leave_region;
}
}
process = &entry->subprocess.process;

if (!(CAP_GET & entry->supported_capabilities))
return -1;
if (!(CAP_GET & entry->supported_capabilities)) {
err = -1;
goto leave_region;
}

sigchain_push(SIGPIPE, SIG_IGN);

Expand Down Expand Up @@ -975,6 +980,10 @@ static int read_object_process(const struct object_id *oid)

trace_performance_since(start, "read_object_process");

leave_region:
trace2_region_leave_printf("subprocess", "read_object", the_repository,
"result %d", err);

return err;
}

Expand Down
2 changes: 1 addition & 1 deletion trace2/tr2_tgt_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static struct tr2_dst tr2dst_event = { TR2_SYSENV_EVENT, 0, 0, 0 };
* event target. Use the TR2_SYSENV_EVENT_NESTING setting to increase
* region details in the event target.
*/
static int tr2env_event_max_nesting_levels = 2;
static int tr2env_event_max_nesting_levels = 4;

/*
* Use the TR2_SYSENV_EVENT_BRIEF to omit the <time>, <file>, and
Expand Down
Loading

0 comments on commit d762feb

Please sign in to comment.