Skip to content

Commit d762feb

Browse files
jeffhostetlerdscho
authored andcommitted
Merge branch 'vfs-trace2'
Includes gvfs-specific commits from PR#115
2 parents 036b953 + c12bd0e commit d762feb

15 files changed

+250
-17
lines changed

builtin/checkout.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "unpack-trees.h"
2727
#include "wt-status.h"
2828
#include "xdiff-interface.h"
29+
#include "packfile.h"
2930

3031
static const char * const checkout_usage[] = {
3132
N_("git checkout [<options>] <branch>"),
@@ -905,8 +906,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
905906
remove_branch_state(the_repository, !opts->quiet);
906907
strbuf_release(&msg);
907908
if (!opts->quiet &&
908-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
909+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
910+
unsigned long nr_unpack_entry_at_start;
911+
912+
trace2_region_enter("tracking", "report_tracking", the_repository);
913+
nr_unpack_entry_at_start = get_nr_unpack_entry();
909914
report_tracking(new_branch_info);
915+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
916+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
917+
trace2_region_leave("tracking", "report_tracking", the_repository);
918+
}
910919
}
911920

912921
static int add_pending_uninteresting_ref(const char *refname,

builtin/commit.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
149149
static int do_serialize = 0;
150150
static char *serialize_path = NULL;
151151

152+
static int reject_implicit = 0;
152153
static int do_implicit_deserialize = 0;
153154
static int do_explicit_deserialize = 0;
154155
static char *deserialize_path = NULL;
@@ -211,7 +212,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
211212
deserialize_path = xstrdup(arg);
212213
}
213214
if (deserialize_path && *deserialize_path
214-
&& (access(deserialize_path, R_OK) != 0))
215+
&& (wt_status_deserialize_access(deserialize_path, R_OK) != 0))
215216
die("cannot find serialization file '%s'",
216217
deserialize_path);
217218

@@ -1417,6 +1418,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
14171418
if (v && *v && access(v, R_OK) == 0) {
14181419
do_implicit_deserialize = 1;
14191420
deserialize_path = xstrdup(v);
1421+
} else {
1422+
reject_implicit = 1;
14201423
}
14211424
return 0;
14221425
}
@@ -1573,6 +1576,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
15731576
(do_implicit_deserialize || do_explicit_deserialize));
15741577
if (try_deserialize)
15751578
goto skip_init;
1579+
/*
1580+
* If we implicitly received a status cache pathname from the config
1581+
* and the file does not exist, we silently reject it and do the normal
1582+
* status "collect". Fake up some trace2 messages to reflect this and
1583+
* assist post-processors know this case is different.
1584+
*/
1585+
if (!do_serialize && reject_implicit) {
1586+
trace2_cmd_mode("implicit-deserialize");
1587+
trace2_data_string("status", the_repository, "deserialize/reject",
1588+
"status-cache/access");
1589+
}
15761590

15771591
enable_fscache(0);
15781592
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1616,6 +1630,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16161630
if (s.relative_paths)
16171631
s.prefix = prefix;
16181632

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

1651+
trace2_cmd_mode("collect");
16361652
wt_status_collect(&s);
16371653

16381654
if (0 <= fd)
@@ -1647,6 +1663,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16471663
if (fd_serialize < 0)
16481664
die_errno(_("could not serialize to '%s'"),
16491665
serialize_path);
1666+
trace2_cmd_mode("serialize");
16501667
wt_status_serialize_v1(fd_serialize, &s);
16511668
close(fd_serialize);
16521669
}

cache-tree.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,31 @@ static void discard_unused_subtrees(struct cache_tree *it)
221221
}
222222
}
223223

224-
int cache_tree_fully_valid(struct cache_tree *it)
224+
static int cache_tree_fully_valid_1(struct cache_tree *it)
225225
{
226226
int i;
227227
if (!it)
228228
return 0;
229229
if (it->entry_count < 0 || !has_object_file(&it->oid))
230230
return 0;
231231
for (i = 0; i < it->subtree_nr; i++) {
232-
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
232+
if (!cache_tree_fully_valid_1(it->down[i]->cache_tree))
233233
return 0;
234234
}
235235
return 1;
236236
}
237237

238+
int cache_tree_fully_valid(struct cache_tree *it)
239+
{
240+
int result;
241+
242+
trace2_region_enter("cache_tree", "fully_valid", NULL);
243+
result = cache_tree_fully_valid_1(it);
244+
trace2_region_leave("cache_tree", "fully_valid", NULL);
245+
246+
return result;
247+
}
248+
238249
static int update_one(struct cache_tree *it,
239250
struct cache_entry **cache,
240251
int entries,
@@ -715,10 +726,14 @@ void prime_cache_tree(struct repository *r,
715726
struct index_state *istate,
716727
struct tree *tree)
717728
{
729+
trace2_region_enter("cache_tree", "prime_cache_tree", r);
730+
718731
cache_tree_free(&istate->cache_tree);
719732
istate->cache_tree = cache_tree();
720733
prime_cache_tree_rec(r, istate->cache_tree, tree);
721734
istate->cache_changed |= CACHE_TREE_CHANGED;
735+
736+
trace2_region_leave("cache_tree", "prime_cache_tree", r);
722737
}
723738

724739
/*

compat/mingw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,6 +3226,8 @@ int wmain(int argc, const wchar_t **wargv)
32263226

32273227
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
32283228

3229+
trace2_initialize_clock();
3230+
32293231
maybe_redirect_std_handles();
32303232
adjust_symlink_flags();
32313233
fsync_object_files = 1;

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,13 @@ static void *read_object(struct repository *r,
16461646
return content;
16471647
}
16481648

1649+
static unsigned long g_nr_unpack_entry;
1650+
1651+
unsigned long get_nr_unpack_entry(void)
1652+
{
1653+
return g_nr_unpack_entry;
1654+
}
1655+
16491656
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16501657
enum object_type *final_type, unsigned long *final_size)
16511658
{
@@ -1659,6 +1666,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16591666
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16601667
int base_from_cache = 0;
16611668

1669+
g_nr_unpack_entry++;
1670+
16621671
write_pack_access_log(p, obj_offset);
16631672

16641673
/* PHASE 1: drill down to the innermost base object */

packfile.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,9 @@ int is_promisor_object(const struct object_id *oid);
193193
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
194194
size_t idx_size, struct packed_git *p);
195195

196+
/*
197+
* Return the number of objects fetched from a packfile.
198+
*/
199+
unsigned long get_nr_unpack_entry(void);
200+
196201
#endif

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,10 @@ static int read_index_extension(struct index_state *istate,
17011701
{
17021702
switch (CACHE_EXT(ext)) {
17031703
case CACHE_EXT_TREE:
1704+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
17041705
istate->cache_tree = cache_tree_read(data, sz);
1706+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1707+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
17051708
break;
17061709
case CACHE_EXT_RESOLVE_UNDO:
17071710
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -1957,6 +1960,17 @@ static void *load_index_extensions(void *_data)
19571960
return NULL;
19581961
}
19591962

1963+
static void *load_index_extensions_threadproc(void *_data)
1964+
{
1965+
void *result;
1966+
1967+
trace2_thread_start("load_index_extensions");
1968+
result = load_index_extensions(_data);
1969+
trace2_thread_exit();
1970+
1971+
return result;
1972+
}
1973+
19601974
/*
19611975
* A helper function that will load the specified range of cache entries
19621976
* from the memory mapped file and add them to the given index.
@@ -2032,12 +2046,17 @@ static void *load_cache_entries_thread(void *_data)
20322046
struct load_cache_entries_thread_data *p = _data;
20332047
int i;
20342048

2049+
trace2_thread_start("load_cache_entries");
2050+
20352051
/* iterate across all ieot blocks assigned to this thread */
20362052
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
20372053
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
20382054
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
20392055
p->offset += p->ieot->entries[i].nr;
20402056
}
2057+
2058+
trace2_thread_exit();
2059+
20412060
return NULL;
20422061
}
20432062

@@ -2187,7 +2206,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
21872206
int err;
21882207

21892208
p.src_offset = extension_offset;
2190-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2209+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
21912210
if (err)
21922211
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
21932212

@@ -2935,9 +2954,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
29352954
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
29362955
struct strbuf sb = STRBUF_INIT;
29372956

2957+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
29382958
cache_tree_write(&sb, istate->cache_tree);
29392959
err = write_index_ext_header(&c, &eoie_c, newfd, CACHE_EXT_TREE, sb.len) < 0
29402960
|| ce_write(&c, newfd, sb.buf, sb.len) < 0;
2961+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
2962+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
2963+
29412964
strbuf_release(&sb);
29422965
if (err)
29432966
return -1;

remote.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
20032003
char *base;
20042004
int upstream_is_gone = 0;
20052005

2006+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
20062007
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2008+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2009+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2010+
if (abf == AHEAD_BEHIND_FULL) {
2011+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2012+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2013+
}
2014+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2015+
20072016
if (sti < 0) {
20082017
if (!full_base)
20092018
return 0;

sha1-file.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,8 @@ static int read_object_process(const struct object_id *oid)
904904

905905
start = getnanotime();
906906

907+
trace2_region_enter("subprocess", "read_object", the_repository);
908+
907909
if (!subprocess_map_initialized) {
908910
subprocess_map_initialized = 1;
909911
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -920,13 +922,16 @@ static int read_object_process(const struct object_id *oid)
920922
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
921923
start_read_object_fn)) {
922924
free(entry);
923-
return -1;
925+
err = -1;
926+
goto leave_region;
924927
}
925928
}
926929
process = &entry->subprocess.process;
927930

928-
if (!(CAP_GET & entry->supported_capabilities))
929-
return -1;
931+
if (!(CAP_GET & entry->supported_capabilities)) {
932+
err = -1;
933+
goto leave_region;
934+
}
930935

931936
sigchain_push(SIGPIPE, SIG_IGN);
932937

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

976981
trace_performance_since(start, "read_object_process");
977982

983+
leave_region:
984+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
985+
"result %d", err);
986+
978987
return err;
979988
}
980989

trace2/tr2_tgt_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static struct tr2_dst tr2dst_event = { TR2_SYSENV_EVENT, 0, 0, 0 };
3232
* event target. Use the TR2_SYSENV_EVENT_NESTING setting to increase
3333
* region details in the event target.
3434
*/
35-
static int tr2env_event_max_nesting_levels = 2;
35+
static int tr2env_event_max_nesting_levels = 4;
3636

3737
/*
3838
* Use the TR2_SYSENV_EVENT_BRIEF to omit the <time>, <file>, and

0 commit comments

Comments
 (0)