Skip to content

Commit 3f67141

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 0f4f4e2 + 82fe914 commit 3f67141

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"
@@ -977,8 +978,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
977978
remove_branch_state(the_repository, !opts->quiet);
978979
strbuf_release(&msg);
979980
if (!opts->quiet &&
980-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
981+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
982+
unsigned long nr_unpack_entry_at_start;
983+
984+
trace2_region_enter("tracking", "report_tracking", the_repository);
985+
nr_unpack_entry_at_start = get_nr_unpack_entry();
981986
report_tracking(new_branch_info);
987+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
988+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
989+
trace2_region_leave("tracking", "report_tracking", the_repository);
990+
}
982991
}
983992

984993
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
@@ -163,6 +163,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
163163
static int do_serialize = 0;
164164
static char *serialize_path = NULL;
165165

166+
static int reject_implicit = 0;
166167
static int do_implicit_deserialize = 0;
167168
static int do_explicit_deserialize = 0;
168169
static char *deserialize_path = NULL;
@@ -226,7 +227,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
226227
}
227228
if (!deserialize_path || !*deserialize_path)
228229
do_explicit_deserialize = 1; /* read stdin */
229-
else if (access(deserialize_path, R_OK) == 0)
230+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
230231
do_explicit_deserialize = 1; /* can read from this file */
231232
else {
232233
/*
@@ -1564,6 +1565,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
15641565
if (v && *v && access(v, R_OK) == 0) {
15651566
do_implicit_deserialize = 1;
15661567
deserialize_path = xstrdup(v);
1568+
} else {
1569+
reject_implicit = 1;
15671570
}
15681571
return 0;
15691572
}
@@ -1728,6 +1731,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17281731

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

17321746
enable_fscache(0);
17331747
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1771,6 +1785,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17711785
if (s.relative_paths)
17721786
s.prefix = prefix;
17731787

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

1806+
trace2_cmd_mode("collect");
17911807
wt_status_collect(&s);
17921808

17931809
if (0 <= fd)
@@ -1802,6 +1818,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18021818
if (fd_serialize < 0)
18031819
die_errno(_("could not serialize to '%s'"),
18041820
serialize_path);
1821+
trace2_cmd_mode("serialize");
18051822
wt_status_serialize_v1(fd_serialize, &s);
18061823
close(fd_serialize);
18071824
}

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
@@ -3954,6 +3954,8 @@ int wmain(int argc, const wchar_t **wargv)
39543954

39553955
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
39563956

3957+
trace2_initialize_clock();
3958+
39573959
maybe_redirect_std_handles();
39583960
adjust_symlink_flags();
39593961
fsync_object_files = 1;

object-file.c

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

978978
start = getnanotime();
979979

980+
trace2_region_enter("subprocess", "read_object", the_repository);
981+
980982
if (!subprocess_map_initialized) {
981983
subprocess_map_initialized = 1;
982984
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -993,13 +995,16 @@ static int read_object_process(const struct object_id *oid)
993995
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
994996
start_read_object_fn)) {
995997
free(entry);
996-
return -1;
998+
err = -1;
999+
goto leave_region;
9971000
}
9981001
}
9991002
process = &entry->subprocess.process;
10001003

1001-
if (!(CAP_GET & entry->supported_capabilities))
1002-
return -1;
1004+
if (!(CAP_GET & entry->supported_capabilities)) {
1005+
err = -1;
1006+
goto leave_region;
1007+
}
10031008

10041009
sigchain_push(SIGPIPE, SIG_IGN);
10051010

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

10491054
trace_performance_since(start, "read_object_process");
10501055

1056+
leave_region:
1057+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
1058+
"result %d", err);
1059+
10511060
return err;
10521061
}
10531062

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,13 @@ static void *read_object(struct repository *r,
16781678
return content;
16791679
}
16801680

1681+
static unsigned long g_nr_unpack_entry;
1682+
1683+
unsigned long get_nr_unpack_entry(void)
1684+
{
1685+
return g_nr_unpack_entry;
1686+
}
1687+
16811688
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16821689
enum object_type *final_type, unsigned long *final_size)
16831690
{
@@ -1691,6 +1698,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16911698
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16921699
int base_from_cache = 0;
16931700

1701+
g_nr_unpack_entry++;
1702+
16941703
write_pack_access_log(p, obj_offset);
16951704

16961705
/* 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
@@ -1850,7 +1850,10 @@ static int read_index_extension(struct index_state *istate,
18501850
{
18511851
switch (CACHE_EXT(ext)) {
18521852
case CACHE_EXT_TREE:
1853+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
18531854
istate->cache_tree = cache_tree_read(data, sz);
1855+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1856+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
18541857
break;
18551858
case CACHE_EXT_RESOLVE_UNDO:
18561859
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2116,6 +2119,17 @@ static void *load_index_extensions(void *_data)
21162119
return NULL;
21172120
}
21182121

2122+
static void *load_index_extensions_threadproc(void *_data)
2123+
{
2124+
void *result;
2125+
2126+
trace2_thread_start("load_index_extensions");
2127+
result = load_index_extensions(_data);
2128+
trace2_thread_exit();
2129+
2130+
return result;
2131+
}
2132+
21192133
/*
21202134
* A helper function that will load the specified range of cache entries
21212135
* from the memory mapped file and add them to the given index.
@@ -2192,12 +2206,17 @@ static void *load_cache_entries_thread(void *_data)
21922206
struct load_cache_entries_thread_data *p = _data;
21932207
int i;
21942208

2209+
trace2_thread_start("load_cache_entries");
2210+
21952211
/* iterate across all ieot blocks assigned to this thread */
21962212
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21972213
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21982214
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21992215
p->offset += p->ieot->entries[i].nr;
22002216
}
2217+
2218+
trace2_thread_exit();
2219+
22012220
return NULL;
22022221
}
22032222

@@ -2366,7 +2385,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
23662385
int err;
23672386

23682387
p.src_offset = extension_offset;
2369-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2388+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
23702389
if (err)
23712390
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
23722391

@@ -3075,9 +3094,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30753094
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
30763095
struct strbuf sb = STRBUF_INIT;
30773096

3097+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30783098
cache_tree_write(&sb, istate->cache_tree);
30793099
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
30803100
hashwrite(f, sb.buf, sb.len);
3101+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3102+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3103+
30813104
strbuf_release(&sb);
30823105
if (err)
30833106
return -1;

remote.c

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

2277+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
22772278
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2279+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2280+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2281+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2282+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2283+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2284+
}
2285+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2286+
22782287
if (sti < 0) {
22792288
if (!full_base)
22802289
return 0;

trace2/tr2_tgt_event.c

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

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

0 commit comments

Comments
 (0)