Skip to content

Commit 10ece56

Browse files
jeffhostetlerderrickstolee
authored andcommitted
Merge trace2 experimental regions
Includes gvfs-specific commits from these pull requests: #158 #159 #160 #164 Signed-off-by: Derrick Stolee <[email protected]>
2 parents 99a88a2 + 9664602 commit 10ece56

15 files changed

+240
-16
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>"),
@@ -933,8 +934,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
933934
remove_branch_state(the_repository, !opts->quiet);
934935
strbuf_release(&msg);
935936
if (!opts->quiet &&
936-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
937+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
938+
unsigned long nr_unpack_entry_at_start;
939+
940+
trace2_region_enter("tracking", "report_tracking", the_repository);
941+
nr_unpack_entry_at_start = get_nr_unpack_entry();
937942
report_tracking(new_branch_info);
943+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
944+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
945+
trace2_region_leave("tracking", "report_tracking", the_repository);
946+
}
938947
}
939948

940949
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
@@ -151,6 +151,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
151151
static int do_serialize = 0;
152152
static char *serialize_path = NULL;
153153

154+
static int reject_implicit = 0;
154155
static int do_implicit_deserialize = 0;
155156
static int do_explicit_deserialize = 0;
156157
static char *deserialize_path = NULL;
@@ -214,7 +215,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
214215
}
215216
if (!deserialize_path || !*deserialize_path)
216217
do_explicit_deserialize = 1; /* read stdin */
217-
else if (access(deserialize_path, R_OK) == 0)
218+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
218219
do_explicit_deserialize = 1; /* can read from this file */
219220
else {
220221
/*
@@ -1447,6 +1448,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
14471448
if (v && *v && access(v, R_OK) == 0) {
14481449
do_implicit_deserialize = 1;
14491450
deserialize_path = xstrdup(v);
1451+
} else {
1452+
reject_implicit = 1;
14501453
}
14511454
return 0;
14521455
}
@@ -1619,6 +1622,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16191622

16201623
if (try_deserialize)
16211624
goto skip_init;
1625+
/*
1626+
* If we implicitly received a status cache pathname from the config
1627+
* and the file does not exist, we silently reject it and do the normal
1628+
* status "collect". Fake up some trace2 messages to reflect this and
1629+
* assist post-processors know this case is different.
1630+
*/
1631+
if (!do_serialize && reject_implicit) {
1632+
trace2_cmd_mode("implicit-deserialize");
1633+
trace2_data_string("status", the_repository, "deserialize/reject",
1634+
"status-cache/access");
1635+
}
16221636

16231637
enable_fscache(0);
16241638
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1662,6 +1676,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16621676
if (s.relative_paths)
16631677
s.prefix = prefix;
16641678

1679+
trace2_cmd_mode("deserialize");
16651680
result = wt_status_deserialize(&s, deserialize_path, dw);
16661681
if (result == DESERIALIZE_OK)
16671682
return 0;
@@ -1679,6 +1694,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16791694
fd = -1;
16801695
}
16811696

1697+
trace2_cmd_mode("collect");
16821698
wt_status_collect(&s);
16831699

16841700
if (0 <= fd)
@@ -1693,6 +1709,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16931709
if (fd_serialize < 0)
16941710
die_errno(_("could not serialize to '%s'"),
16951711
serialize_path);
1712+
trace2_cmd_mode("serialize");
16961713
wt_status_serialize_v1(fd_serialize, &s);
16971714
close(fd_serialize);
16981715
}

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,
@@ -757,10 +768,14 @@ void prime_cache_tree(struct repository *r,
757768
struct index_state *istate,
758769
struct tree *tree)
759770
{
771+
trace2_region_enter("cache_tree", "prime_cache_tree", r);
772+
760773
cache_tree_free(&istate->cache_tree);
761774
istate->cache_tree = cache_tree();
762775
prime_cache_tree_rec(r, istate->cache_tree, tree);
763776
istate->cache_changed |= CACHE_TREE_CHANGED;
777+
778+
trace2_region_leave("cache_tree", "prime_cache_tree", r);
764779
}
765780

766781
/*

compat/mingw.c

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

36813681
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
36823682

3683+
trace2_initialize_clock();
3684+
36833685
maybe_redirect_std_handles();
36843686
adjust_symlink_flags();
36853687
fsync_object_files = 1;

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,13 @@ static void *read_object(struct repository *r,
16551655
return content;
16561656
}
16571657

1658+
static unsigned long g_nr_unpack_entry;
1659+
1660+
unsigned long get_nr_unpack_entry(void)
1661+
{
1662+
return g_nr_unpack_entry;
1663+
}
1664+
16581665
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16591666
enum object_type *final_type, unsigned long *final_size)
16601667
{
@@ -1668,6 +1675,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16681675
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16691676
int base_from_cache = 0;
16701677

1678+
g_nr_unpack_entry++;
1679+
16711680
write_pack_access_log(p, obj_offset);
16721681

16731682
/* 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
@@ -189,4 +189,9 @@ int is_promisor_object(const struct object_id *oid);
189189
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
190190
size_t idx_size, struct packed_git *p);
191191

192+
/*
193+
* Return the number of objects fetched from a packfile.
194+
*/
195+
unsigned long get_nr_unpack_entry(void);
196+
192197
#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
@@ -1989,7 +1989,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
19891989
char *base;
19901990
int upstream_is_gone = 0;
19911991

1992+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
19921993
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
1994+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
1995+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
1996+
if (abf == AHEAD_BEHIND_FULL) {
1997+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
1998+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
1999+
}
2000+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2001+
19932002
if (sti < 0) {
19942003
if (!full_base)
19952004
return 0;

sha1-file.c

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

917917
start = getnanotime();
918918

919+
trace2_region_enter("subprocess", "read_object", the_repository);
920+
919921
if (!subprocess_map_initialized) {
920922
subprocess_map_initialized = 1;
921923
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -932,13 +934,16 @@ static int read_object_process(const struct object_id *oid)
932934
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
933935
start_read_object_fn)) {
934936
free(entry);
935-
return -1;
937+
err = -1;
938+
goto leave_region;
936939
}
937940
}
938941
process = &entry->subprocess.process;
939942

940-
if (!(CAP_GET & entry->supported_capabilities))
941-
return -1;
943+
if (!(CAP_GET & entry->supported_capabilities)) {
944+
err = -1;
945+
goto leave_region;
946+
}
942947

943948
sigchain_push(SIGPIPE, SIG_IGN);
944949

@@ -987,6 +992,10 @@ static int read_object_process(const struct object_id *oid)
987992

988993
trace_performance_since(start, "read_object_process");
989994

995+
leave_region:
996+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
997+
"result %d", err);
998+
990999
return err;
9911000
}
9921001

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)