Skip to content

Commit d030032

Browse files
jeffhostetlerderrickstolee
authored andcommitted
Merge trace2 experimental regions
Includes gvfs-specific commits from these pull requests: git-for-windows#158 git-for-windows#159 git-for-windows#160 git-for-windows#164 Signed-off-by: Derrick Stolee <[email protected]>
2 parents 1b8ce67 + 1691c79 commit d030032

15 files changed

+237
-20
lines changed

builtin/checkout.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "lockfile.h"
1414
#include "merge-recursive.h"
1515
#include "object-store.h"
16+
#include "packfile.h"
1617
#include "parse-options.h"
1718
#include "refs.h"
1819
#include "remote.h"
@@ -953,8 +954,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
953954
remove_branch_state(the_repository, !opts->quiet);
954955
strbuf_release(&msg);
955956
if (!opts->quiet &&
956-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
957+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
958+
unsigned long nr_unpack_entry_at_start;
959+
960+
trace2_region_enter("tracking", "report_tracking", the_repository);
961+
nr_unpack_entry_at_start = get_nr_unpack_entry();
957962
report_tracking(new_branch_info);
963+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
964+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
965+
trace2_region_leave("tracking", "report_tracking", the_repository);
966+
}
958967
}
959968

960969
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
@@ -161,6 +161,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
161161
static int do_serialize = 0;
162162
static char *serialize_path = NULL;
163163

164+
static int reject_implicit = 0;
164165
static int do_implicit_deserialize = 0;
165166
static int do_explicit_deserialize = 0;
166167
static char *deserialize_path = NULL;
@@ -224,7 +225,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
224225
}
225226
if (!deserialize_path || !*deserialize_path)
226227
do_explicit_deserialize = 1; /* read stdin */
227-
else if (access(deserialize_path, R_OK) == 0)
228+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
228229
do_explicit_deserialize = 1; /* can read from this file */
229230
else {
230231
/*
@@ -1562,6 +1563,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
15621563
if (v && *v && access(v, R_OK) == 0) {
15631564
do_implicit_deserialize = 1;
15641565
deserialize_path = xstrdup(v);
1566+
} else {
1567+
reject_implicit = 1;
15651568
}
15661569
return 0;
15671570
}
@@ -1737,6 +1740,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17371740

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

17411755
enable_fscache(0);
17421756
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1780,6 +1794,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17801794
if (s.relative_paths)
17811795
s.prefix = prefix;
17821796

1797+
trace2_cmd_mode("deserialize");
17831798
result = wt_status_deserialize(&s, deserialize_path, dw);
17841799
if (result == DESERIALIZE_OK)
17851800
return 0;
@@ -1797,6 +1812,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17971812
fd = -1;
17981813
}
17991814

1815+
trace2_cmd_mode("collect");
18001816
wt_status_collect(&s);
18011817

18021818
if (0 <= fd)
@@ -1811,6 +1827,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18111827
if (fd_serialize < 0)
18121828
die_errno(_("could not serialize to '%s'"),
18131829
serialize_path);
1830+
trace2_cmd_mode("serialize");
18141831
wt_status_serialize_v1(fd_serialize, &s);
18151832
close(fd_serialize);
18161833
}

cache-tree.c

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

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

246+
int cache_tree_fully_valid(struct cache_tree *it)
247+
{
248+
int result;
249+
250+
trace2_region_enter("cache_tree", "fully_valid", NULL);
251+
result = cache_tree_fully_valid_1(it);
252+
trace2_region_leave("cache_tree", "fully_valid", NULL);
253+
254+
return result;
255+
}
256+
246257
static int update_one(struct cache_tree *it,
247258
struct cache_entry **cache,
248259
int entries,
@@ -796,13 +807,13 @@ void prime_cache_tree(struct repository *r,
796807
struct index_state *istate,
797808
struct tree *tree)
798809
{
799-
trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
810+
trace2_region_enter("cache-tree", "prime_cache_tree", r);
800811
cache_tree_free(&istate->cache_tree);
801812
istate->cache_tree = cache_tree();
802813

803814
prime_cache_tree_rec(r, istate->cache_tree, tree);
804815
istate->cache_changed |= CACHE_TREE_CHANGED;
805-
trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
816+
trace2_region_leave("cache-tree", "prime_cache_tree", r);
806817
}
807818

808819
/*

compat/mingw.c

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

37513751
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
37523752

3753+
trace2_initialize_clock();
3754+
37533755
maybe_redirect_std_handles();
37543756
adjust_symlink_flags();
37553757
fsync_object_files = 1;

object-file.c

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

982982
start = getnanotime();
983983

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

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

10081013
sigchain_push(SIGPIPE, SIG_IGN);
10091014

@@ -1052,6 +1057,10 @@ static int read_object_process(const struct object_id *oid)
10521057

10531058
trace_performance_since(start, "read_object_process");
10541059

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

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,13 @@ static void *read_object(struct repository *r,
16731673
return content;
16741674
}
16751675

1676+
static unsigned long g_nr_unpack_entry;
1677+
1678+
unsigned long get_nr_unpack_entry(void)
1679+
{
1680+
return g_nr_unpack_entry;
1681+
}
1682+
16761683
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16771684
enum object_type *final_type, unsigned long *final_size)
16781685
{
@@ -1686,6 +1693,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16861693
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16871694
int base_from_cache = 0;
16881695

1696+
g_nr_unpack_entry++;
1697+
16891698
write_pack_access_log(p, obj_offset);
16901699

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

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

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,10 @@ static int read_index_extension(struct index_state *istate,
18041804
{
18051805
switch (CACHE_EXT(ext)) {
18061806
case CACHE_EXT_TREE:
1807+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
18071808
istate->cache_tree = cache_tree_read(data, sz);
1809+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1810+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
18081811
break;
18091812
case CACHE_EXT_RESOLVE_UNDO:
18101813
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2063,6 +2066,17 @@ static void *load_index_extensions(void *_data)
20632066
return NULL;
20642067
}
20652068

2069+
static void *load_index_extensions_threadproc(void *_data)
2070+
{
2071+
void *result;
2072+
2073+
trace2_thread_start("load_index_extensions");
2074+
result = load_index_extensions(_data);
2075+
trace2_thread_exit();
2076+
2077+
return result;
2078+
}
2079+
20662080
/*
20672081
* A helper function that will load the specified range of cache entries
20682082
* from the memory mapped file and add them to the given index.
@@ -2139,12 +2153,17 @@ static void *load_cache_entries_thread(void *_data)
21392153
struct load_cache_entries_thread_data *p = _data;
21402154
int i;
21412155

2156+
trace2_thread_start("load_cache_entries");
2157+
21422158
/* iterate across all ieot blocks assigned to this thread */
21432159
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21442160
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21452161
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21462162
p->offset += p->ieot->entries[i].nr;
21472163
}
2164+
2165+
trace2_thread_exit();
2166+
21482167
return NULL;
21492168
}
21502169

@@ -2297,7 +2316,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22972316
int err;
22982317

22992318
p.src_offset = extension_offset;
2300-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2319+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
23012320
if (err)
23022321
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
23032322

@@ -2985,9 +3004,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
29853004
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
29863005
struct strbuf sb = STRBUF_INIT;
29873006

3007+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
29883008
cache_tree_write(&sb, istate->cache_tree);
29893009
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
29903010
hashwrite(f, sb.buf, sb.len);
3011+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3012+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3013+
29913014
strbuf_release(&sb);
29923015
if (err)
29933016
return -1;

remote.c

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

2109+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
21092110
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2111+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2112+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2113+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2114+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2115+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2116+
}
2117+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2118+
21102119
if (sti < 0) {
21112120
if (!full_base)
21122121
return 0;

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)