Skip to content

Commit 03020a3

Browse files
jeffhostetlerderrickstolee
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 649085a + b807e0e commit 03020a3

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"
@@ -987,8 +988,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
987988
remove_branch_state(the_repository, !opts->quiet);
988989
strbuf_release(&msg);
989990
if (!opts->quiet &&
990-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
991+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
992+
unsigned long nr_unpack_entry_at_start;
993+
994+
trace2_region_enter("tracking", "report_tracking", the_repository);
995+
nr_unpack_entry_at_start = get_nr_unpack_entry();
991996
report_tracking(new_branch_info);
997+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
998+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
999+
trace2_region_leave("tracking", "report_tracking", the_repository);
1000+
}
9921001
}
9931002

9941003
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
/*
@@ -1575,6 +1576,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
15751576
if (v && *v && access(v, R_OK) == 0) {
15761577
do_implicit_deserialize = 1;
15771578
deserialize_path = xstrdup(v);
1579+
} else {
1580+
reject_implicit = 1;
15781581
}
15791582
return 0;
15801583
}
@@ -1729,6 +1732,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17291732

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

17331747
enable_fscache(0);
17341748
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1772,6 +1786,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17721786
if (s.relative_paths)
17731787
s.prefix = prefix;
17741788

1789+
trace2_cmd_mode("deserialize");
17751790
result = wt_status_deserialize(&s, deserialize_path, dw);
17761791
if (result == DESERIALIZE_OK)
17771792
return 0;
@@ -1789,6 +1804,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17891804
fd = -1;
17901805
}
17911806

1807+
trace2_cmd_mode("collect");
17921808
wt_status_collect(&s);
17931809

17941810
if (0 <= fd)
@@ -1803,6 +1819,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18031819
if (fd_serialize < 0)
18041820
die_errno(_("could not serialize to '%s'"),
18051821
serialize_path);
1822+
trace2_cmd_mode("serialize");
18061823
wt_status_serialize_v1(fd_serialize, &s);
18071824
close(fd_serialize);
18081825
}

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,
@@ -839,14 +850,14 @@ void prime_cache_tree(struct repository *r,
839850
{
840851
struct strbuf tree_path = STRBUF_INIT;
841852

842-
trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
853+
trace2_region_enter("cache-tree", "prime_cache_tree", r);
843854
cache_tree_free(&istate->cache_tree);
844855
istate->cache_tree = cache_tree();
845856

846857
prime_cache_tree_rec(r, istate->cache_tree, tree, &tree_path);
847858
strbuf_release(&tree_path);
848859
istate->cache_changed |= CACHE_TREE_CHANGED;
849-
trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
860+
trace2_region_leave("cache-tree", "prime_cache_tree", r);
850861
}
851862

852863
/*

compat/mingw.c

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

39733973
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
39743974

3975+
trace2_initialize_clock();
3976+
39753977
maybe_redirect_std_handles();
39763978
adjust_symlink_flags();
39773979
fsync_object_files = 1;

object-file.c

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

983983
start = getnanotime();
984984

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

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

10091014
sigchain_push(SIGPIPE, SIG_IGN);
10101015

@@ -1053,6 +1058,10 @@ static int read_object_process(const struct object_id *oid)
10531058

10541059
trace_performance_since(start, "read_object_process");
10551060

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

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,13 @@ static void *read_object(struct repository *r,
16661666
return content;
16671667
}
16681668

1669+
static unsigned long g_nr_unpack_entry;
1670+
1671+
unsigned long get_nr_unpack_entry(void)
1672+
{
1673+
return g_nr_unpack_entry;
1674+
}
1675+
16691676
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16701677
enum object_type *final_type, unsigned long *final_size)
16711678
{
@@ -1679,6 +1686,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16791686
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16801687
int base_from_cache = 0;
16811688

1689+
g_nr_unpack_entry++;
1690+
16821691
write_pack_access_log(p, obj_offset);
16831692

16841693
/* 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
@@ -1855,7 +1855,10 @@ static int read_index_extension(struct index_state *istate,
18551855
{
18561856
switch (CACHE_EXT(ext)) {
18571857
case CACHE_EXT_TREE:
1858+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
18581859
istate->cache_tree = cache_tree_read(data, sz);
1860+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1861+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
18591862
break;
18601863
case CACHE_EXT_RESOLVE_UNDO:
18611864
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2144,6 +2147,17 @@ static void *load_index_extensions(void *_data)
21442147
return NULL;
21452148
}
21462149

2150+
static void *load_index_extensions_threadproc(void *_data)
2151+
{
2152+
void *result;
2153+
2154+
trace2_thread_start("load_index_extensions");
2155+
result = load_index_extensions(_data);
2156+
trace2_thread_exit();
2157+
2158+
return result;
2159+
}
2160+
21472161
/*
21482162
* A helper function that will load the specified range of cache entries
21492163
* from the memory mapped file and add them to the given index.
@@ -2220,12 +2234,17 @@ static void *load_cache_entries_thread(void *_data)
22202234
struct load_cache_entries_thread_data *p = _data;
22212235
int i;
22222236

2237+
trace2_thread_start("load_cache_entries");
2238+
22232239
/* iterate across all ieot blocks assigned to this thread */
22242240
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
22252241
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
22262242
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
22272243
p->offset += p->ieot->entries[i].nr;
22282244
}
2245+
2246+
trace2_thread_exit();
2247+
22292248
return NULL;
22302249
}
22312250

@@ -2396,7 +2415,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
23962415
int err;
23972416

23982417
p.src_offset = extension_offset;
2399-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2418+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
24002419
if (err)
24012420
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
24022421

@@ -3103,9 +3122,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
31033122
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
31043123
struct strbuf sb = STRBUF_INIT;
31053124

3125+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
31063126
cache_tree_write(&sb, istate->cache_tree);
31073127
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
31083128
hashwrite(f, sb.buf, sb.len);
3129+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3130+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3131+
31093132
strbuf_release(&sb);
31103133
if (err)
31113134
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)