Skip to content

Commit 7c9df03

Browse files
jeffhostetlerderrickstolee
authored andcommitted
Merge branch 'vfs-trace2'
Includes gvfs-specific commits from PR#115
2 parents 2bab82c + b4fa368 commit 7c9df03

15 files changed

+242
-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>"),
@@ -909,8 +910,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
909910
remove_branch_state(the_repository, !opts->quiet);
910911
strbuf_release(&msg);
911912
if (!opts->quiet &&
912-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
913+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
914+
unsigned long nr_unpack_entry_at_start;
915+
916+
trace2_region_enter("tracking", "report_tracking", the_repository);
917+
nr_unpack_entry_at_start = get_nr_unpack_entry();
913918
report_tracking(new_branch_info);
919+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
920+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
921+
trace2_region_leave("tracking", "report_tracking", the_repository);
922+
}
914923
}
915924

916925
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

@@ -1435,6 +1436,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
14351436
if (v && *v && access(v, R_OK) == 0) {
14361437
do_implicit_deserialize = 1;
14371438
deserialize_path = xstrdup(v);
1439+
} else {
1440+
reject_implicit = 1;
14381441
}
14391442
return 0;
14401443
}
@@ -1591,6 +1594,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
15911594
(do_implicit_deserialize || do_explicit_deserialize));
15921595
if (try_deserialize)
15931596
goto skip_init;
1597+
/*
1598+
* If we implicitly received a status cache pathname from the config
1599+
* and the file does not exist, we silently reject it and do the normal
1600+
* status "collect". Fake up some trace2 messages to reflect this and
1601+
* assist post-processors know this case is different.
1602+
*/
1603+
if (!do_serialize && reject_implicit) {
1604+
trace2_cmd_mode("implicit-deserialize");
1605+
trace2_data_string("status", the_repository, "deserialize/reject",
1606+
"status-cache/access");
1607+
}
15941608

15951609
enable_fscache(0);
15961610
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1634,6 +1648,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16341648
if (s.relative_paths)
16351649
s.prefix = prefix;
16361650

1651+
trace2_cmd_mode("deserialize");
16371652
result = wt_status_deserialize(&s, deserialize_path, dw);
16381653
if (result == DESERIALIZE_OK)
16391654
return 0;
@@ -1651,6 +1666,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16511666
fd = -1;
16521667
}
16531668

1669+
trace2_cmd_mode("collect");
16541670
wt_status_collect(&s);
16551671

16561672
if (0 <= fd)
@@ -1665,6 +1681,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16651681
if (fd_serialize < 0)
16661682
die_errno(_("could not serialize to '%s'"),
16671683
serialize_path);
1684+
trace2_cmd_mode("serialize");
16681685
wt_status_serialize_v1(fd_serialize, &s);
16691686
close(fd_serialize);
16701687
}

cache-tree.c

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

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

239+
int cache_tree_fully_valid(struct cache_tree *it)
240+
{
241+
int result;
242+
243+
trace2_region_enter("cache_tree", "fully_valid", NULL);
244+
result = cache_tree_fully_valid_1(it);
245+
trace2_region_leave("cache_tree", "fully_valid", NULL);
246+
247+
return result;
248+
}
249+
239250
static int update_one(struct cache_tree *it,
240251
struct cache_entry **cache,
241252
int entries,
@@ -755,10 +766,14 @@ void prime_cache_tree(struct repository *r,
755766
struct index_state *istate,
756767
struct tree *tree)
757768
{
769+
trace2_region_enter("cache_tree", "prime_cache_tree", r);
770+
758771
cache_tree_free(&istate->cache_tree);
759772
istate->cache_tree = cache_tree();
760773
prime_cache_tree_rec(r, istate->cache_tree, tree);
761774
istate->cache_changed |= CACHE_TREE_CHANGED;
775+
776+
trace2_region_leave("cache_tree", "prime_cache_tree", r);
762777
}
763778

764779
/*

compat/mingw.c

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

36323632
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
36333633

3634+
trace2_initialize_clock();
3635+
36343636
maybe_redirect_std_handles();
36353637
adjust_symlink_flags();
36363638
fsync_object_files = 1;

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,13 @@ static void *read_object(struct repository *r,
16231623
return content;
16241624
}
16251625

1626+
static unsigned long g_nr_unpack_entry;
1627+
1628+
unsigned long get_nr_unpack_entry(void)
1629+
{
1630+
return g_nr_unpack_entry;
1631+
}
1632+
16261633
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16271634
enum object_type *final_type, unsigned long *final_size)
16281635
{
@@ -1636,6 +1643,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16361643
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16371644
int base_from_cache = 0;
16381645

1646+
g_nr_unpack_entry++;
1647+
16391648
write_pack_access_log(p, obj_offset);
16401649

16411650
/* 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
@@ -1739,7 +1739,10 @@ static int read_index_extension(struct index_state *istate,
17391739
{
17401740
switch (CACHE_EXT(ext)) {
17411741
case CACHE_EXT_TREE:
1742+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
17421743
istate->cache_tree = cache_tree_read(data, sz);
1744+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1745+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
17431746
break;
17441747
case CACHE_EXT_RESOLVE_UNDO:
17451748
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -1994,6 +1997,17 @@ static void *load_index_extensions(void *_data)
19941997
return NULL;
19951998
}
19961999

2000+
static void *load_index_extensions_threadproc(void *_data)
2001+
{
2002+
void *result;
2003+
2004+
trace2_thread_start("load_index_extensions");
2005+
result = load_index_extensions(_data);
2006+
trace2_thread_exit();
2007+
2008+
return result;
2009+
}
2010+
19972011
/*
19982012
* A helper function that will load the specified range of cache entries
19992013
* from the memory mapped file and add them to the given index.
@@ -2069,12 +2083,17 @@ static void *load_cache_entries_thread(void *_data)
20692083
struct load_cache_entries_thread_data *p = _data;
20702084
int i;
20712085

2086+
trace2_thread_start("load_cache_entries");
2087+
20722088
/* iterate across all ieot blocks assigned to this thread */
20732089
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
20742090
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
20752091
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
20762092
p->offset += p->ieot->entries[i].nr;
20772093
}
2094+
2095+
trace2_thread_exit();
2096+
20782097
return NULL;
20792098
}
20802099

@@ -2224,7 +2243,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22242243
int err;
22252244

22262245
p.src_offset = extension_offset;
2227-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2246+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
22282247
if (err)
22292248
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
22302249

@@ -2972,9 +2991,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
29722991
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
29732992
struct strbuf sb = STRBUF_INIT;
29742993

2994+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
29752995
cache_tree_write(&sb, istate->cache_tree);
29762996
err = write_index_ext_header(&c, &eoie_c, newfd, CACHE_EXT_TREE, sb.len) < 0
29772997
|| ce_write(&c, newfd, sb.buf, sb.len) < 0;
2998+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
2999+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3000+
29783001
strbuf_release(&sb);
29793002
if (err)
29803003
return -1;

remote.c

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

2009+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
20092010
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2011+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2012+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2013+
if (abf == AHEAD_BEHIND_FULL) {
2014+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2015+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2016+
}
2017+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2018+
20102019
if (sti < 0) {
20112020
if (!full_base)
20122021
return 0;

sha1-file.c

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

904904
start = getnanotime();
905905

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

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

930935
sigchain_push(SIGPIPE, SIG_IGN);
931936

@@ -974,6 +979,10 @@ static int read_object_process(const struct object_id *oid)
974979

975980
trace_performance_since(start, "read_object_process");
976981

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

trace2/tr2_tgt_event.c

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

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

0 commit comments

Comments
 (0)