Skip to content

Commit 56ac9e9

Browse files
jeffhostetlerdscho
authored andcommitted
Merge trace2 experimental regions
Includes gvfs-specific commits from these pull requests: git#158 git#159 git#160 git#164 Signed-off-by: Derrick Stolee <[email protected]>
2 parents 9240c0f + f7abc13 commit 56ac9e9

15 files changed

+237
-20
lines changed

builtin/checkout.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "lockfile.h"
1515
#include "merge-recursive.h"
1616
#include "object-store.h"
17+
#include "packfile.h"
1718
#include "parse-options.h"
1819
#include "refs.h"
1920
#include "remote.h"
@@ -989,8 +990,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
989990
remove_branch_state(the_repository, !opts->quiet);
990991
strbuf_release(&msg);
991992
if (!opts->quiet &&
992-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
993+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
994+
unsigned long nr_unpack_entry_at_start;
995+
996+
trace2_region_enter("tracking", "report_tracking", the_repository);
997+
nr_unpack_entry_at_start = get_nr_unpack_entry();
993998
report_tracking(new_branch_info);
999+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
1000+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
1001+
trace2_region_leave("tracking", "report_tracking", the_repository);
1002+
}
9941003
}
9951004

9961005
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
@@ -170,6 +170,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
170170
static int do_serialize = 0;
171171
static char *serialize_path = NULL;
172172

173+
static int reject_implicit = 0;
173174
static int do_implicit_deserialize = 0;
174175
static int do_explicit_deserialize = 0;
175176
static char *deserialize_path = NULL;
@@ -233,7 +234,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
233234
}
234235
if (!deserialize_path || !*deserialize_path)
235236
do_explicit_deserialize = 1; /* read stdin */
236-
else if (access(deserialize_path, R_OK) == 0)
237+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
237238
do_explicit_deserialize = 1; /* can read from this file */
238239
else {
239240
/*
@@ -1578,6 +1579,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
15781579
if (v && *v && access(v, R_OK) == 0) {
15791580
do_implicit_deserialize = 1;
15801581
deserialize_path = xstrdup(v);
1582+
} else {
1583+
reject_implicit = 1;
15811584
}
15821585
return 0;
15831586
}
@@ -1732,6 +1735,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17321735

17331736
if (try_deserialize)
17341737
goto skip_init;
1738+
/*
1739+
* If we implicitly received a status cache pathname from the config
1740+
* and the file does not exist, we silently reject it and do the normal
1741+
* status "collect". Fake up some trace2 messages to reflect this and
1742+
* assist post-processors know this case is different.
1743+
*/
1744+
if (!do_serialize && reject_implicit) {
1745+
trace2_cmd_mode("implicit-deserialize");
1746+
trace2_data_string("status", the_repository, "deserialize/reject",
1747+
"status-cache/access");
1748+
}
17351749

17361750
enable_fscache(0);
17371751
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1775,6 +1789,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17751789
if (s.relative_paths)
17761790
s.prefix = prefix;
17771791

1792+
trace2_cmd_mode("deserialize");
17781793
result = wt_status_deserialize(&s, deserialize_path, dw);
17791794
if (result == DESERIALIZE_OK)
17801795
return 0;
@@ -1792,6 +1807,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17921807
fd = -1;
17931808
}
17941809

1810+
trace2_cmd_mode("collect");
17951811
wt_status_collect(&s);
17961812

17971813
if (0 <= fd)
@@ -1806,6 +1822,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18061822
if (fd_serialize < 0)
18071823
die_errno(_("could not serialize to '%s'"),
18081824
serialize_path);
1825+
trace2_cmd_mode("serialize");
18091826
wt_status_serialize_v1(fd_serialize, &s);
18101827
close(fd_serialize);
18111828
}

cache-tree.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,15 @@ static void discard_unused_subtrees(struct cache_tree *it)
225225
}
226226
}
227227

228-
int cache_tree_fully_valid(struct cache_tree *it)
228+
static int cache_tree_fully_valid_1(struct cache_tree *it)
229229
{
230230
int i;
231231
if (!it)
232232
return 0;
233233
if (it->entry_count < 0 || !has_object_file(&it->oid))
234234
return 0;
235235
for (i = 0; i < it->subtree_nr; i++) {
236-
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
236+
if (!cache_tree_fully_valid_1(it->down[i]->cache_tree))
237237
return 0;
238238
}
239239
return 1;
@@ -244,6 +244,17 @@ static int must_check_existence(const struct cache_entry *ce)
244244
return !(has_promisor_remote() && ce_skip_worktree(ce));
245245
}
246246

247+
int cache_tree_fully_valid(struct cache_tree *it)
248+
{
249+
int result;
250+
251+
trace2_region_enter("cache_tree", "fully_valid", NULL);
252+
result = cache_tree_fully_valid_1(it);
253+
trace2_region_leave("cache_tree", "fully_valid", NULL);
254+
255+
return result;
256+
}
257+
247258
static int update_one(struct cache_tree *it,
248259
struct cache_entry **cache,
249260
int entries,
@@ -838,14 +849,14 @@ void prime_cache_tree(struct repository *r,
838849
{
839850
struct strbuf tree_path = STRBUF_INIT;
840851

841-
trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
852+
trace2_region_enter("cache-tree", "prime_cache_tree", r);
842853
cache_tree_free(&istate->cache_tree);
843854
istate->cache_tree = cache_tree();
844855

845856
prime_cache_tree_rec(r, istate->cache_tree, tree, &tree_path);
846857
strbuf_release(&tree_path);
847858
istate->cache_changed |= CACHE_TREE_CHANGED;
848-
trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
859+
trace2_region_leave("cache-tree", "prime_cache_tree", r);
849860
}
850861

851862
/*

compat/mingw.c

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

39823982
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
39833983

3984+
trace2_initialize_clock();
3985+
39843986
maybe_redirect_std_handles();
39853987
adjust_symlink_flags();
39863988
fsync_object_files = 1;

object-file.c

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

984984
start = getnanotime();
985985

986+
trace2_region_enter("subprocess", "read_object", the_repository);
987+
986988
if (!subprocess_map_initialized) {
987989
subprocess_map_initialized = 1;
988990
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -999,13 +1001,16 @@ static int read_object_process(const struct object_id *oid)
9991001
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
10001002
start_read_object_fn)) {
10011003
free(entry);
1002-
return -1;
1004+
err = -1;
1005+
goto leave_region;
10031006
}
10041007
}
10051008
process = &entry->subprocess.process;
10061009

1007-
if (!(CAP_GET & entry->supported_capabilities))
1008-
return -1;
1010+
if (!(CAP_GET & entry->supported_capabilities)) {
1011+
err = -1;
1012+
goto leave_region;
1013+
}
10091014

10101015
sigchain_push(SIGPIPE, SIG_IGN);
10111016

@@ -1054,6 +1059,10 @@ static int read_object_process(const struct object_id *oid)
10541059

10551060
trace_performance_since(start, "read_object_process");
10561061

1062+
leave_region:
1063+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
1064+
"result %d", err);
1065+
10571066
return err;
10581067
}
10591068

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,13 @@ struct unpack_entry_stack_ent {
16501650
unsigned long size;
16511651
};
16521652

1653+
static unsigned long g_nr_unpack_entry;
1654+
1655+
unsigned long get_nr_unpack_entry(void)
1656+
{
1657+
return g_nr_unpack_entry;
1658+
}
1659+
16531660
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16541661
enum object_type *final_type, unsigned long *final_size)
16551662
{
@@ -1663,6 +1670,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16631670
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16641671
int base_from_cache = 0;
16651672

1673+
g_nr_unpack_entry++;
1674+
16661675
write_pack_access_log(p, obj_offset);
16671676

16681677
/* 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
@@ -195,4 +195,9 @@ int is_promisor_object(const struct object_id *oid);
195195
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
196196
size_t idx_size, struct packed_git *p);
197197

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

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,10 @@ static int read_index_extension(struct index_state *istate,
18631863
{
18641864
switch (CACHE_EXT(ext)) {
18651865
case CACHE_EXT_TREE:
1866+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
18661867
istate->cache_tree = cache_tree_read(data, sz);
1868+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1869+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
18671870
break;
18681871
case CACHE_EXT_RESOLVE_UNDO:
18691872
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2152,6 +2155,17 @@ static void *load_index_extensions(void *_data)
21522155
return NULL;
21532156
}
21542157

2158+
static void *load_index_extensions_threadproc(void *_data)
2159+
{
2160+
void *result;
2161+
2162+
trace2_thread_start("load_index_extensions");
2163+
result = load_index_extensions(_data);
2164+
trace2_thread_exit();
2165+
2166+
return result;
2167+
}
2168+
21552169
/*
21562170
* A helper function that will load the specified range of cache entries
21572171
* from the memory mapped file and add them to the given index.
@@ -2228,12 +2242,17 @@ static void *load_cache_entries_thread(void *_data)
22282242
struct load_cache_entries_thread_data *p = _data;
22292243
int i;
22302244

2245+
trace2_thread_start("load_cache_entries");
2246+
22312247
/* iterate across all ieot blocks assigned to this thread */
22322248
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
22332249
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
22342250
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
22352251
p->offset += p->ieot->entries[i].nr;
22362252
}
2253+
2254+
trace2_thread_exit();
2255+
22372256
return NULL;
22382257
}
22392258

@@ -2400,7 +2419,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
24002419
int err;
24012420

24022421
p.src_offset = extension_offset;
2403-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2422+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
24042423
if (err)
24052424
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
24062425

@@ -3115,9 +3134,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
31153134
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
31163135
struct strbuf sb = STRBUF_INIT;
31173136

3137+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
31183138
cache_tree_write(&sb, istate->cache_tree);
31193139
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
31203140
hashwrite(f, sb.buf, sb.len);
3141+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3142+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3143+
31213144
strbuf_release(&sb);
31223145
if (err)
31233146
return -1;

remote.c

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

2258+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
22582259
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2260+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2261+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2262+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2263+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2264+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2265+
}
2266+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2267+
22592268
if (sti < 0) {
22602269
if (!full_base)
22612270
return 0;

trace2/tr2_tgt_event.c

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

4141
/*
4242
* Use the TR2_SYSENV_EVENT_BRIEF to omit the <time>, <file>, and

0 commit comments

Comments
 (0)