Skip to content

Commit 4cff3b4

Browse files
jeffhostetlerdscho
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 a18a6d4 + 91209e5 commit 4cff3b4

15 files changed

+238
-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"
@@ -958,8 +959,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
958959
remove_branch_state(the_repository, !opts->quiet);
959960
strbuf_release(&msg);
960961
if (!opts->quiet &&
961-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
962+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
963+
unsigned long nr_unpack_entry_at_start;
964+
965+
trace2_region_enter("tracking", "report_tracking", the_repository);
966+
nr_unpack_entry_at_start = get_nr_unpack_entry();
962967
report_tracking(new_branch_info);
968+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
969+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
970+
trace2_region_leave("tracking", "report_tracking", the_repository);
971+
}
963972
}
964973

965974
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
/*
@@ -1555,6 +1556,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
15551556
if (v && *v && access(v, R_OK) == 0) {
15561557
do_implicit_deserialize = 1;
15571558
deserialize_path = xstrdup(v);
1559+
} else {
1560+
reject_implicit = 1;
15581561
}
15591562
return 0;
15601563
}
@@ -1727,6 +1730,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17271730

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

17311745
enable_fscache(0);
17321746
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1770,6 +1784,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17701784
if (s.relative_paths)
17711785
s.prefix = prefix;
17721786

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

1805+
trace2_cmd_mode("collect");
17901806
wt_status_collect(&s);
17911807

17921808
if (0 <= fd)
@@ -1801,6 +1817,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18011817
if (fd_serialize < 0)
18021818
die_errno(_("could not serialize to '%s'"),
18031819
serialize_path);
1820+
trace2_cmd_mode("serialize");
18041821
wt_status_serialize_v1(fd_serialize, &s);
18051822
close(fd_serialize);
18061823
}

cache-tree.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,31 @@ 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;
239239
}
240240

241+
int cache_tree_fully_valid(struct cache_tree *it)
242+
{
243+
int result;
244+
245+
trace2_region_enter("cache_tree", "fully_valid", NULL);
246+
result = cache_tree_fully_valid_1(it);
247+
trace2_region_leave("cache_tree", "fully_valid", NULL);
248+
249+
return result;
250+
}
251+
241252
static int update_one(struct cache_tree *it,
242253
struct cache_entry **cache,
243254
int entries,
@@ -791,13 +802,13 @@ void prime_cache_tree(struct repository *r,
791802
struct index_state *istate,
792803
struct tree *tree)
793804
{
794-
trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
805+
trace2_region_enter("cache-tree", "prime_cache_tree", r);
795806
cache_tree_free(&istate->cache_tree);
796807
istate->cache_tree = cache_tree();
797808

798809
prime_cache_tree_rec(r, istate->cache_tree, tree);
799810
istate->cache_changed |= CACHE_TREE_CHANGED;
800-
trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
811+
trace2_region_leave("cache-tree", "prime_cache_tree", r);
801812
}
802813

803814
/*

compat/mingw.c

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

37303730
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
37313731

3732+
trace2_initialize_clock();
3733+
37323734
maybe_redirect_std_handles();
37333735
adjust_symlink_flags();
37343736
fsync_object_files = 1;

object-file.c

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

973973
start = getnanotime();
974974

975+
trace2_region_enter("subprocess", "read_object", the_repository);
976+
975977
if (!subprocess_map_initialized) {
976978
subprocess_map_initialized = 1;
977979
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -988,13 +990,16 @@ static int read_object_process(const struct object_id *oid)
988990
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
989991
start_read_object_fn)) {
990992
free(entry);
991-
return -1;
993+
err = -1;
994+
goto leave_region;
992995
}
993996
}
994997
process = &entry->subprocess.process;
995998

996-
if (!(CAP_GET & entry->supported_capabilities))
997-
return -1;
999+
if (!(CAP_GET & entry->supported_capabilities)) {
1000+
err = -1;
1001+
goto leave_region;
1002+
}
9981003

9991004
sigchain_push(SIGPIPE, SIG_IGN);
10001005

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

10441049
trace_performance_since(start, "read_object_process");
10451050

1051+
leave_region:
1052+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
1053+
"result %d", err);
1054+
10461055
return err;
10471056
}
10481057

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
@@ -1799,7 +1799,10 @@ static int read_index_extension(struct index_state *istate,
17991799
{
18001800
switch (CACHE_EXT(ext)) {
18011801
case CACHE_EXT_TREE:
1802+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
18021803
istate->cache_tree = cache_tree_read(data, sz);
1804+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1805+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
18031806
break;
18041807
case CACHE_EXT_RESOLVE_UNDO:
18051808
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2058,6 +2061,17 @@ static void *load_index_extensions(void *_data)
20582061
return NULL;
20592062
}
20602063

2064+
static void *load_index_extensions_threadproc(void *_data)
2065+
{
2066+
void *result;
2067+
2068+
trace2_thread_start("load_index_extensions");
2069+
result = load_index_extensions(_data);
2070+
trace2_thread_exit();
2071+
2072+
return result;
2073+
}
2074+
20612075
/*
20622076
* A helper function that will load the specified range of cache entries
20632077
* from the memory mapped file and add them to the given index.
@@ -2134,12 +2148,17 @@ static void *load_cache_entries_thread(void *_data)
21342148
struct load_cache_entries_thread_data *p = _data;
21352149
int i;
21362150

2151+
trace2_thread_start("load_cache_entries");
2152+
21372153
/* iterate across all ieot blocks assigned to this thread */
21382154
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21392155
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21402156
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21412157
p->offset += p->ieot->entries[i].nr;
21422158
}
2159+
2160+
trace2_thread_exit();
2161+
21432162
return NULL;
21442163
}
21452164

@@ -2291,7 +2310,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22912310
int err;
22922311

22932312
p.src_offset = extension_offset;
2294-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2313+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
22952314
if (err)
22962315
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
22972316

@@ -3048,9 +3067,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30483067
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
30493068
struct strbuf sb = STRBUF_INIT;
30503069

3070+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30513071
cache_tree_write(&sb, istate->cache_tree);
30523072
err = write_index_ext_header(&c, &eoie_c, newfd, CACHE_EXT_TREE, sb.len) < 0
30533073
|| ce_write(&c, newfd, sb.buf, sb.len) < 0;
3074+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3075+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3076+
30543077
strbuf_release(&sb);
30553078
if (err)
30563079
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 (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)