Skip to content

Commit a25cba0

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 <[email protected]>
2 parents ff2be29 + 2be5e4d commit a25cba0

15 files changed

+240
-18
lines changed

builtin/checkout.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "merge-recursive.h"
2121
#include "object-name.h"
2222
#include "object-store-ll.h"
23+
#include "packfile.h"
2324
#include "parse-options.h"
2425
#include "path.h"
2526
#include "preload-index.h"
@@ -1049,8 +1050,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
10491050
strbuf_release(&msg);
10501051
if (!opts->quiet &&
10511052
!opts->force_detach &&
1052-
(new_branch_info->path || !strcmp(new_branch_info->name, "HEAD")))
1053+
(new_branch_info->path || !strcmp(new_branch_info->name, "HEAD"))) {
1054+
unsigned long nr_unpack_entry_at_start;
1055+
1056+
trace2_region_enter("tracking", "report_tracking", the_repository);
1057+
nr_unpack_entry_at_start = get_nr_unpack_entry();
10531058
report_tracking(new_branch_info);
1059+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
1060+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
1061+
trace2_region_leave("tracking", "report_tracking", the_repository);
1062+
}
10541063
}
10551064

10561065
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
/*
@@ -1609,6 +1610,8 @@ static int git_status_config(const char *k, const char *v,
16091610
if (v && *v && access(v, R_OK) == 0) {
16101611
do_implicit_deserialize = 1;
16111612
deserialize_path = xstrdup(v);
1613+
} else {
1614+
reject_implicit = 1;
16121615
}
16131616
return 0;
16141617
}
@@ -1762,6 +1765,17 @@ struct repository *repo UNUSED)
17621765

17631766
if (try_deserialize)
17641767
goto skip_init;
1768+
/*
1769+
* If we implicitly received a status cache pathname from the config
1770+
* and the file does not exist, we silently reject it and do the normal
1771+
* status "collect". Fake up some trace2 messages to reflect this and
1772+
* assist post-processors know this case is different.
1773+
*/
1774+
if (!do_serialize && reject_implicit) {
1775+
trace2_cmd_mode("implicit-deserialize");
1776+
trace2_data_string("status", the_repository, "deserialize/reject",
1777+
"status-cache/access");
1778+
}
17651779

17661780
enable_fscache(0);
17671781
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1805,6 +1819,7 @@ struct repository *repo UNUSED)
18051819
if (s.relative_paths)
18061820
s.prefix = prefix;
18071821

1822+
trace2_cmd_mode("deserialize");
18081823
result = wt_status_deserialize(&s, deserialize_path, dw);
18091824
if (result == DESERIALIZE_OK)
18101825
return 0;
@@ -1822,6 +1837,7 @@ struct repository *repo UNUSED)
18221837
fd = -1;
18231838
}
18241839

1840+
trace2_cmd_mode("collect");
18251841
wt_status_collect(&s);
18261842

18271843
if (0 <= fd)
@@ -1836,6 +1852,7 @@ struct repository *repo UNUSED)
18361852
if (fd_serialize < 0)
18371853
die_errno(_("could not serialize to '%s'"),
18381854
serialize_path);
1855+
trace2_cmd_mode("serialize");
18391856
wt_status_serialize_v1(fd_serialize, &s);
18401857
close(fd_serialize);
18411858
}

cache-tree.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ 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)
241241
return 0;
242242
if (it->entry_count < 0 || !repo_has_object_file(the_repository, &it->oid))
243243
return 0;
244244
for (i = 0; i < it->subtree_nr; i++) {
245-
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
245+
if (!cache_tree_fully_valid_1(it->down[i]->cache_tree))
246246
return 0;
247247
}
248248
return 1;
@@ -253,6 +253,17 @@ static int must_check_existence(const struct cache_entry *ce)
253253
return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
254254
}
255255

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

compat/mingw.c

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

43264326
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
43274327

4328+
trace2_initialize_clock();
4329+
43284330
maybe_redirect_std_handles();
43294331
adjust_symlink_flags();
43304332
fsync_object_files = 1;

object-file.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "loose.h"
4343
#include "object-file-convert.h"
4444
#include "trace.h"
45+
#include "trace2.h"
4546
#include "hook.h"
4647
#include "sigchain.h"
4748
#include "sub-process.h"
@@ -1061,6 +1062,8 @@ static int read_object_process(const struct object_id *oid)
10611062

10621063
start = getnanotime();
10631064

1065+
trace2_region_enter("subprocess", "read_object", the_repository);
1066+
10641067
if (!subprocess_map_initialized) {
10651068
subprocess_map_initialized = 1;
10661069
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -1077,13 +1080,16 @@ static int read_object_process(const struct object_id *oid)
10771080
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
10781081
start_read_object_fn)) {
10791082
free(entry);
1080-
return -1;
1083+
err = -1;
1084+
goto leave_region;
10811085
}
10821086
}
10831087
process = &entry->subprocess.process;
10841088

1085-
if (!(CAP_GET & entry->supported_capabilities))
1086-
return -1;
1089+
if (!(CAP_GET & entry->supported_capabilities)) {
1090+
err = -1;
1091+
goto leave_region;
1092+
}
10871093

10881094
sigchain_push(SIGPIPE, SIG_IGN);
10891095

@@ -1132,6 +1138,10 @@ static int read_object_process(const struct object_id *oid)
11321138

11331139
trace_performance_since(start, "read_object_process");
11341140

1141+
leave_region:
1142+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
1143+
"result %d", err);
1144+
11351145
strbuf_release(&status);
11361146
return err;
11371147
}

packfile.c

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

1698+
static unsigned long g_nr_unpack_entry;
1699+
1700+
unsigned long get_nr_unpack_entry(void)
1701+
{
1702+
return g_nr_unpack_entry;
1703+
}
1704+
16981705
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16991706
enum object_type *final_type, unsigned long *final_size)
17001707
{
@@ -1708,6 +1715,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
17081715
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
17091716
int base_from_cache = 0;
17101717

1718+
g_nr_unpack_entry++;
1719+
17111720
prepare_repo_settings(p->repo);
17121721

17131722
write_pack_access_log(p, obj_offset);

packfile.h

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

225+
/*
226+
* Return the number of objects fetched from a packfile.
227+
*/
228+
unsigned long get_nr_unpack_entry(void);
229+
225230
#endif

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,10 @@ static int read_index_extension(struct index_state *istate,
17641764
{
17651765
switch (CACHE_EXT(ext)) {
17661766
case CACHE_EXT_TREE:
1767+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
17671768
istate->cache_tree = cache_tree_read(data, sz);
1769+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1770+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
17681771
break;
17691772
case CACHE_EXT_RESOLVE_UNDO:
17701773
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2054,6 +2057,17 @@ static void *load_index_extensions(void *_data)
20542057
return NULL;
20552058
}
20562059

2060+
static void *load_index_extensions_threadproc(void *_data)
2061+
{
2062+
void *result;
2063+
2064+
trace2_thread_start("load_index_extensions");
2065+
result = load_index_extensions(_data);
2066+
trace2_thread_exit();
2067+
2068+
return result;
2069+
}
2070+
20572071
/*
20582072
* A helper function that will load the specified range of cache entries
20592073
* from the memory mapped file and add them to the given index.
@@ -2130,12 +2144,17 @@ static void *load_cache_entries_thread(void *_data)
21302144
struct load_cache_entries_thread_data *p = _data;
21312145
int i;
21322146

2147+
trace2_thread_start("load_cache_entries");
2148+
21332149
/* iterate across all ieot blocks assigned to this thread */
21342150
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21352151
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21362152
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21372153
p->offset += p->ieot->entries[i].nr;
21382154
}
2155+
2156+
trace2_thread_exit();
2157+
21392158
return NULL;
21402159
}
21412160

@@ -2305,7 +2324,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
23052324
int err;
23062325

23072326
p.src_offset = extension_offset;
2308-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2327+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
23092328
if (err)
23102329
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
23112330

@@ -3035,9 +3054,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30353054
!drop_cache_tree && istate->cache_tree) {
30363055
strbuf_reset(&sb);
30373056

3057+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30383058
cache_tree_write(&sb, istate->cache_tree);
30393059
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
30403060
hashwrite(f, sb.buf, sb.len);
3061+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3062+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3063+
30413064
if (err) {
30423065
ret = -1;
30433066
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"
@@ -2374,7 +2375,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
23742375
char *base;
23752376
int upstream_is_gone = 0;
23762377

2378+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
23772379
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2380+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2381+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2382+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2383+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2384+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2385+
}
2386+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2387+
23782388
if (sti < 0) {
23792389
if (!full_base)
23802390
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)