Skip to content

Commit 307f037

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 9b373b2 + 0effeb2 commit 307f037

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 "object-store.h"
24+
#include "packfile.h"
2425
#include "parse-options.h"
2526
#include "path.h"
2627
#include "preload-index.h"
@@ -1050,8 +1051,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
10501051
strbuf_release(&msg);
10511052
if (!opts->quiet &&
10521053
!opts->force_detach &&
1053-
(new_branch_info->path || !strcmp(new_branch_info->name, "HEAD")))
1054+
(new_branch_info->path || !strcmp(new_branch_info->name, "HEAD"))) {
1055+
unsigned long nr_unpack_entry_at_start;
1056+
1057+
trace2_region_enter("tracking", "report_tracking", the_repository);
1058+
nr_unpack_entry_at_start = get_nr_unpack_entry();
10541059
report_tracking(new_branch_info);
1060+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
1061+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
1062+
trace2_region_leave("tracking", "report_tracking", the_repository);
1063+
}
10551064
}
10561065

10571066
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
@@ -168,6 +168,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
168168
static int do_serialize = 0;
169169
static char *serialize_path = NULL;
170170

171+
static int reject_implicit = 0;
171172
static int do_implicit_deserialize = 0;
172173
static int do_explicit_deserialize = 0;
173174
static char *deserialize_path = NULL;
@@ -231,7 +232,7 @@ static int opt_parse_deserialize(const struct option *opt UNUSED, const char *ar
231232
}
232233
if (!deserialize_path || !*deserialize_path)
233234
do_explicit_deserialize = 1; /* read stdin */
234-
else if (access(deserialize_path, R_OK) == 0)
235+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
235236
do_explicit_deserialize = 1; /* can read from this file */
236237
else {
237238
/*
@@ -1611,6 +1612,8 @@ static int git_status_config(const char *k, const char *v,
16111612
if (v && *v && access(v, R_OK) == 0) {
16121613
do_implicit_deserialize = 1;
16131614
deserialize_path = xstrdup(v);
1615+
} else {
1616+
reject_implicit = 1;
16141617
}
16151618
return 0;
16161619
}
@@ -1781,6 +1784,17 @@ struct repository *repo UNUSED)
17811784

17821785
if (try_deserialize)
17831786
goto skip_init;
1787+
/*
1788+
* If we implicitly received a status cache pathname from the config
1789+
* and the file does not exist, we silently reject it and do the normal
1790+
* status "collect". Fake up some trace2 messages to reflect this and
1791+
* assist post-processors know this case is different.
1792+
*/
1793+
if (!do_serialize && reject_implicit) {
1794+
trace2_cmd_mode("implicit-deserialize");
1795+
trace2_data_string("status", the_repository, "deserialize/reject",
1796+
"status-cache/access");
1797+
}
17841798

17851799
enable_fscache(0);
17861800
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1824,6 +1838,7 @@ struct repository *repo UNUSED)
18241838
if (s.relative_paths)
18251839
s.prefix = prefix;
18261840

1841+
trace2_cmd_mode("deserialize");
18271842
result = wt_status_deserialize(&s, deserialize_path, dw);
18281843
if (result == DESERIALIZE_OK)
18291844
return 0;
@@ -1841,6 +1856,7 @@ struct repository *repo UNUSED)
18411856
fd = -1;
18421857
}
18431858

1859+
trace2_cmd_mode("collect");
18441860
wt_status_collect(&s);
18451861

18461862
if (0 <= fd)
@@ -1855,6 +1871,7 @@ struct repository *repo UNUSED)
18551871
if (fd_serialize < 0)
18561872
die_errno(_("could not serialize to '%s'"),
18571873
serialize_path);
1874+
trace2_cmd_mode("serialize");
18581875
wt_status_serialize_v1(fd_serialize, &s);
18591876
close(fd_serialize);
18601877
}

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

43274327
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
43284328

4329+
trace2_initialize_clock();
4330+
43294331
maybe_redirect_std_handles();
43304332
adjust_symlink_flags();
43314333
fsync_object_files = 1;

object-store.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "sub-process.h"
3030
#include "submodule.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 */,
@@ -632,6 +633,8 @@ int read_object_process(const struct object_id *oid)
632633

633634
start = getnanotime();
634635

636+
trace2_region_enter("subprocess", "read_object", the_repository);
637+
635638
if (!subprocess_map_initialized) {
636639
subprocess_map_initialized = 1;
637640
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -648,13 +651,16 @@ int read_object_process(const struct object_id *oid)
648651
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
649652
start_read_object_fn)) {
650653
free(entry);
651-
return -1;
654+
err = -1;
655+
goto leave_region;
652656
}
653657
}
654658
process = &entry->subprocess.process;
655659

656-
if (!(CAP_GET & entry->supported_capabilities))
657-
return -1;
660+
if (!(CAP_GET & entry->supported_capabilities)) {
661+
err = -1;
662+
goto leave_region;
663+
}
658664

659665
sigchain_push(SIGPIPE, SIG_IGN);
660666

@@ -703,6 +709,10 @@ int read_object_process(const struct object_id *oid)
703709

704710
trace_performance_since(start, "read_object_process");
705711

712+
leave_region:
713+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
714+
"result %d", err);
715+
706716
strbuf_release(&status);
707717
return err;
708718
}

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,13 @@ struct unpack_entry_stack_ent {
17021702
unsigned long size;
17031703
};
17041704

1705+
static unsigned long g_nr_unpack_entry;
1706+
1707+
unsigned long get_nr_unpack_entry(void)
1708+
{
1709+
return g_nr_unpack_entry;
1710+
}
1711+
17051712
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
17061713
enum object_type *final_type, unsigned long *final_size)
17071714
{
@@ -1715,6 +1722,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
17151722
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
17161723
int base_from_cache = 0;
17171724

1725+
g_nr_unpack_entry++;
1726+
17181727
prepare_repo_settings(p->repo);
17191728

17201729
write_pack_access_log(p, obj_offset);

packfile.h

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

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

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,10 @@ static int read_index_extension(struct index_state *istate,
17361736
{
17371737
switch (CACHE_EXT(ext)) {
17381738
case CACHE_EXT_TREE:
1739+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
17391740
istate->cache_tree = cache_tree_read(data, sz);
1741+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1742+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
17401743
break;
17411744
case CACHE_EXT_RESOLVE_UNDO:
17421745
istate->resolve_undo = resolve_undo_read(data, sz, the_hash_algo);
@@ -2026,6 +2029,17 @@ static void *load_index_extensions(void *_data)
20262029
return NULL;
20272030
}
20282031

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

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

@@ -2277,7 +2296,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22772296
int err;
22782297

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

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

3029+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30103030
cache_tree_write(&sb, istate->cache_tree);
30113031
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
30123032
hashwrite(f, sb.buf, sb.len);
3033+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3034+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3035+
30133036
if (err) {
30143037
ret = -1;
30153038
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"
@@ -2202,7 +2203,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
22022203
char *base;
22032204
int upstream_is_gone = 0;
22042205

2206+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
22052207
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2208+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2209+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2210+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2211+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2212+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2213+
}
2214+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2215+
22062216
if (sti < 0) {
22072217
if (!full_base)
22082218
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)