Skip to content

Commit 7e4abde

Browse files
jeffhostetlerdscho
authored andcommitted
Merge trace2 experimental regions
Includes gvfs-specific commits from these pull requests: #158 #159 #160 #164 Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
2 parents 98ce79c + 044bdda commit 7e4abde

15 files changed

+240
-18
lines changed

builtin/checkout.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "object-file.h"
2222
#include "object-name.h"
2323
#include "odb.h"
24+
#include "packfile.h"
2425
#include "parse-options.h"
2526
#include "path.h"
2627
#include "preload-index.h"
@@ -1061,8 +1062,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
10611062
strbuf_release(&msg);
10621063
if (!opts->quiet &&
10631064
!opts->force_detach &&
1064-
(new_branch_info->path || !strcmp(new_branch_info->name, "HEAD")))
1065+
(new_branch_info->path || !strcmp(new_branch_info->name, "HEAD"))) {
1066+
unsigned long nr_unpack_entry_at_start;
1067+
1068+
trace2_region_enter("tracking", "report_tracking", the_repository);
1069+
nr_unpack_entry_at_start = get_nr_unpack_entry();
10651070
report_tracking(new_branch_info);
1071+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
1072+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
1073+
trace2_region_leave("tracking", "report_tracking", the_repository);
1074+
}
10661075
}
10671076

10681077
static int add_pending_uninteresting_ref(const char *refname, const char *referent UNUSED,

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 UNUSED, const char *ar
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
/*
@@ -1627,6 +1628,8 @@ static int git_status_config(const char *k, const char *v,
16271628
if (v && *v && access(v, R_OK) == 0) {
16281629
do_implicit_deserialize = 1;
16291630
deserialize_path = xstrdup(v);
1631+
} else {
1632+
reject_implicit = 1;
16301633
}
16311634
return 0;
16321635
}
@@ -1797,6 +1800,17 @@ struct repository *repo UNUSED)
17971800

17981801
if (try_deserialize)
17991802
goto skip_init;
1803+
/*
1804+
* If we implicitly received a status cache pathname from the config
1805+
* and the file does not exist, we silently reject it and do the normal
1806+
* status "collect". Fake up some trace2 messages to reflect this and
1807+
* assist post-processors know this case is different.
1808+
*/
1809+
if (!do_serialize && reject_implicit) {
1810+
trace2_cmd_mode("implicit-deserialize");
1811+
trace2_data_string("status", the_repository, "deserialize/reject",
1812+
"status-cache/access");
1813+
}
18001814

18011815
enable_fscache(0);
18021816
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1840,6 +1854,7 @@ struct repository *repo UNUSED)
18401854
if (s.relative_paths)
18411855
s.prefix = prefix;
18421856

1857+
trace2_cmd_mode("deserialize");
18431858
result = wt_status_deserialize(&s, deserialize_path, dw);
18441859
if (result == DESERIALIZE_OK)
18451860
return 0;
@@ -1857,6 +1872,7 @@ struct repository *repo UNUSED)
18571872
fd = -1;
18581873
}
18591874

1875+
trace2_cmd_mode("collect");
18601876
wt_status_collect(&s);
18611877

18621878
if (0 <= fd)
@@ -1871,6 +1887,7 @@ struct repository *repo UNUSED)
18711887
if (fd_serialize < 0)
18721888
die_errno(_("could not serialize to '%s'"),
18731889
serialize_path);
1890+
trace2_cmd_mode("serialize");
18741891
wt_status_serialize_v1(fd_serialize, &s);
18751892
close(fd_serialize);
18761893
}

cache-tree.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static void discard_unused_subtrees(struct cache_tree *it)
234234
}
235235
}
236236

237-
int cache_tree_fully_valid(struct cache_tree *it)
237+
static int cache_tree_fully_valid_1(struct cache_tree *it)
238238
{
239239
int i;
240240
if (!it)
@@ -244,7 +244,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
244244
HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
245245
return 0;
246246
for (i = 0; i < it->subtree_nr; i++) {
247-
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
247+
if (!cache_tree_fully_valid_1(it->down[i]->cache_tree))
248248
return 0;
249249
}
250250
return 1;
@@ -255,6 +255,17 @@ static int must_check_existence(const struct cache_entry *ce)
255255
return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
256256
}
257257

258+
int cache_tree_fully_valid(struct cache_tree *it)
259+
{
260+
int result;
261+
262+
trace2_region_enter("cache_tree", "fully_valid", NULL);
263+
result = cache_tree_fully_valid_1(it);
264+
trace2_region_leave("cache_tree", "fully_valid", NULL);
265+
266+
return result;
267+
}
268+
258269
static int update_one(struct cache_tree *it,
259270
struct cache_entry **cache,
260271
int entries,

compat/mingw.c

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

43314331
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
43324332

4333+
trace2_initialize_clock();
4334+
43334335
maybe_redirect_std_handles();
43344336
adjust_symlink_flags();
43354337
fsync_object_files = 1;

odb.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "submodule.h"
3030
#include "trace2.h"
3131
#include "trace.h"
32+
#include "trace2.h"
3233
#include "write-or-die.h"
3334

3435
KHASH_INIT(odb_path_map, const char * /* key: odb_path */,
@@ -648,6 +649,8 @@ int read_object_process(struct repository *r, const struct object_id *oid)
648649

649650
start = getnanotime();
650651

652+
trace2_region_enter("subprocess", "read_object",r);
653+
651654
if (!subprocess_map_initialized) {
652655
subprocess_map_initialized = 1;
653656
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -664,13 +667,16 @@ int read_object_process(struct repository *r, const struct object_id *oid)
664667
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
665668
start_read_object_fn)) {
666669
free(entry);
667-
return -1;
670+
err = -1;
671+
goto leave_region;
668672
}
669673
}
670674
process = &entry->subprocess.process;
671675

672-
if (!(CAP_GET & entry->supported_capabilities))
673-
return -1;
676+
if (!(CAP_GET & entry->supported_capabilities)) {
677+
err = -1;
678+
goto leave_region;
679+
}
674680

675681
sigchain_push(SIGPIPE, SIG_IGN);
676682

@@ -719,6 +725,10 @@ int read_object_process(struct repository *r, const struct object_id *oid)
719725

720726
trace_performance_since(start, "read_object_process");
721727

728+
leave_region:
729+
trace2_region_leave_printf("subprocess", "read_object", r,
730+
"result %d", err);
731+
722732
strbuf_release(&status);
723733
return err;
724734
}

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,13 @@ struct unpack_entry_stack_ent {
16931693
unsigned long size;
16941694
};
16951695

1696+
static unsigned long g_nr_unpack_entry;
1697+
1698+
unsigned long get_nr_unpack_entry(void)
1699+
{
1700+
return g_nr_unpack_entry;
1701+
}
1702+
16961703
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16971704
enum object_type *final_type, unsigned long *final_size)
16981705
{
@@ -1706,6 +1713,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
17061713
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
17071714
int base_from_cache = 0;
17081715

1716+
g_nr_unpack_entry++;
1717+
17091718
prepare_repo_settings(p->repo);
17101719

17111720
write_pack_access_log(p, obj_offset);

packfile.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,9 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
299299
*/
300300
int parse_pack_header_option(const char *in, unsigned char *out, unsigned int *len);
301301

302+
/*
303+
* Return the number of objects fetched from a packfile.
304+
*/
305+
unsigned long get_nr_unpack_entry(void);
306+
302307
#endif

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,10 @@ static int read_index_extension(struct index_state *istate,
17371737
{
17381738
switch (CACHE_EXT(ext)) {
17391739
case CACHE_EXT_TREE:
1740+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
17401741
istate->cache_tree = cache_tree_read(data, sz);
1742+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1743+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
17411744
break;
17421745
case CACHE_EXT_RESOLVE_UNDO:
17431746
istate->resolve_undo = resolve_undo_read(data, sz, the_hash_algo);
@@ -2027,6 +2030,17 @@ static void *load_index_extensions(void *_data)
20272030
return NULL;
20282031
}
20292032

2033+
static void *load_index_extensions_threadproc(void *_data)
2034+
{
2035+
void *result;
2036+
2037+
trace2_thread_start("load_index_extensions");
2038+
result = load_index_extensions(_data);
2039+
trace2_thread_exit();
2040+
2041+
return result;
2042+
}
2043+
20302044
/*
20312045
* A helper function that will load the specified range of cache entries
20322046
* from the memory mapped file and add them to the given index.
@@ -2103,12 +2117,17 @@ static void *load_cache_entries_thread(void *_data)
21032117
struct load_cache_entries_thread_data *p = _data;
21042118
int i;
21052119

2120+
trace2_thread_start("load_cache_entries");
2121+
21062122
/* iterate across all ieot blocks assigned to this thread */
21072123
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21082124
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21092125
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21102126
p->offset += p->ieot->entries[i].nr;
21112127
}
2128+
2129+
trace2_thread_exit();
2130+
21122131
return NULL;
21132132
}
21142133

@@ -2278,7 +2297,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22782297
int err;
22792298

22802299
p.src_offset = extension_offset;
2281-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2300+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
22822301
if (err)
22832302
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
22842303

@@ -3008,9 +3027,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30083027
!drop_cache_tree && istate->cache_tree) {
30093028
strbuf_reset(&sb);
30103029

3030+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30113031
cache_tree_write(&sb, istate->cache_tree);
30123032
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
30133033
hashwrite(f, sb.buf, sb.len);
3034+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3035+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3036+
30143037
if (err) {
30153038
ret = -1;
30163039
goto out;

remote.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "setup.h"
2222
#include "string-list.h"
2323
#include "strvec.h"
24+
#include "trace2.h"
2425
#include "commit-reach.h"
2526
#include "advice.h"
2627
#include "connect.h"
@@ -2246,7 +2247,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
22462247
char *base;
22472248
int upstream_is_gone = 0;
22482249

2250+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
22492251
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2252+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2253+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2254+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2255+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2256+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2257+
}
2258+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2259+
22502260
if (sti < 0) {
22512261
if (!full_base)
22522262
return 0;

trace2/tr2_tgt_event.c

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

4444
/*
4545
* Use the TR2_SYSENV_EVENT_BRIEF to omit the <time>, <file>, and

0 commit comments

Comments
 (0)