Skip to content

Commit bc979e9

Browse files
jeffhostetlerderrickstolee
authored andcommitted
Merge trace2 experimental regions
Includes gvfs-specific commits from these pull requests: git#158 git#159 git#160 git#164 Signed-off-by: Derrick Stolee <[email protected]>
2 parents 70f9ea8 + 35ad629 commit bc979e9

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"
@@ -951,8 +952,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
951952
remove_branch_state(the_repository, !opts->quiet);
952953
strbuf_release(&msg);
953954
if (!opts->quiet &&
954-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
955+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
956+
unsigned long nr_unpack_entry_at_start;
957+
958+
trace2_region_enter("tracking", "report_tracking", the_repository);
959+
nr_unpack_entry_at_start = get_nr_unpack_entry();
955960
report_tracking(new_branch_info);
961+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
962+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
963+
trace2_region_leave("tracking", "report_tracking", the_repository);
964+
}
956965
}
957966

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

165+
static int reject_implicit = 0;
165166
static int do_implicit_deserialize = 0;
166167
static int do_explicit_deserialize = 0;
167168
static char *deserialize_path = NULL;
@@ -225,7 +226,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
225226
}
226227
if (!deserialize_path || !*deserialize_path)
227228
do_explicit_deserialize = 1; /* read stdin */
228-
else if (access(deserialize_path, R_OK) == 0)
229+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
229230
do_explicit_deserialize = 1; /* can read from this file */
230231
else {
231232
/*
@@ -1564,6 +1565,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
15641565
if (v && *v && access(v, R_OK) == 0) {
15651566
do_implicit_deserialize = 1;
15661567
deserialize_path = xstrdup(v);
1568+
} else {
1569+
reject_implicit = 1;
15671570
}
15681571
return 0;
15691572
}
@@ -1739,6 +1742,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17391742

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

17431757
enable_fscache(0);
17441758
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1782,6 +1796,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17821796
if (s.relative_paths)
17831797
s.prefix = prefix;
17841798

1799+
trace2_cmd_mode("deserialize");
17851800
result = wt_status_deserialize(&s, deserialize_path, dw);
17861801
if (result == DESERIALIZE_OK)
17871802
return 0;
@@ -1799,6 +1814,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17991814
fd = -1;
18001815
}
18011816

1817+
trace2_cmd_mode("collect");
18021818
wt_status_collect(&s);
18031819

18041820
if (0 <= fd)
@@ -1813,6 +1829,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18131829
if (fd_serialize < 0)
18141830
die_errno(_("could not serialize to '%s'"),
18151831
serialize_path);
1832+
trace2_cmd_mode("serialize");
18161833
wt_status_serialize_v1(fd_serialize, &s);
18171834
close(fd_serialize);
18181835
}

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,
@@ -797,13 +808,13 @@ void prime_cache_tree(struct repository *r,
797808
struct index_state *istate,
798809
struct tree *tree)
799810
{
800-
trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
811+
trace2_region_enter("cache-tree", "prime_cache_tree", r);
801812
cache_tree_free(&istate->cache_tree);
802813
istate->cache_tree = cache_tree();
803814

804815
prime_cache_tree_rec(r, istate->cache_tree, tree);
805816
istate->cache_changed |= CACHE_TREE_CHANGED;
806-
trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
817+
trace2_region_leave("cache-tree", "prime_cache_tree", r);
807818
}
808819

809820
/*

compat/mingw.c

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

37563756
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
37573757

3758+
trace2_initialize_clock();
3759+
37583760
maybe_redirect_std_handles();
37593761
adjust_symlink_flags();
37603762
fsync_object_files = FSYNC_OBJECT_FILES_ON;

object-file.c

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

980980
start = getnanotime();
981981

982+
trace2_region_enter("subprocess", "read_object", the_repository);
983+
982984
if (!subprocess_map_initialized) {
983985
subprocess_map_initialized = 1;
984986
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -995,13 +997,16 @@ static int read_object_process(const struct object_id *oid)
995997
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
996998
start_read_object_fn)) {
997999
free(entry);
998-
return -1;
1000+
err = -1;
1001+
goto leave_region;
9991002
}
10001003
}
10011004
process = &entry->subprocess.process;
10021005

1003-
if (!(CAP_GET & entry->supported_capabilities))
1004-
return -1;
1006+
if (!(CAP_GET & entry->supported_capabilities)) {
1007+
err = -1;
1008+
goto leave_region;
1009+
}
10051010

10061011
sigchain_push(SIGPIPE, SIG_IGN);
10071012

@@ -1050,6 +1055,10 @@ static int read_object_process(const struct object_id *oid)
10501055

10511056
trace_performance_since(start, "read_object_process");
10521057

1058+
leave_region:
1059+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
1060+
"result %d", err);
1061+
10531062
return err;
10541063
}
10551064

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,13 @@ static void *read_object(struct repository *r,
16621662
return content;
16631663
}
16641664

1665+
static unsigned long g_nr_unpack_entry;
1666+
1667+
unsigned long get_nr_unpack_entry(void)
1668+
{
1669+
return g_nr_unpack_entry;
1670+
}
1671+
16651672
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16661673
enum object_type *final_type, unsigned long *final_size)
16671674
{
@@ -1675,6 +1682,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16751682
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16761683
int base_from_cache = 0;
16771684

1685+
g_nr_unpack_entry++;
1686+
16781687
write_pack_access_log(p, obj_offset);
16791688

16801689
/* 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
@@ -1819,7 +1819,10 @@ static int read_index_extension(struct index_state *istate,
18191819
{
18201820
switch (CACHE_EXT(ext)) {
18211821
case CACHE_EXT_TREE:
1822+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
18221823
istate->cache_tree = cache_tree_read(data, sz);
1824+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1825+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
18231826
break;
18241827
case CACHE_EXT_RESOLVE_UNDO:
18251828
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2087,6 +2090,17 @@ static void *load_index_extensions(void *_data)
20872090
return NULL;
20882091
}
20892092

2093+
static void *load_index_extensions_threadproc(void *_data)
2094+
{
2095+
void *result;
2096+
2097+
trace2_thread_start("load_index_extensions");
2098+
result = load_index_extensions(_data);
2099+
trace2_thread_exit();
2100+
2101+
return result;
2102+
}
2103+
20902104
/*
20912105
* A helper function that will load the specified range of cache entries
20922106
* from the memory mapped file and add them to the given index.
@@ -2163,12 +2177,17 @@ static void *load_cache_entries_thread(void *_data)
21632177
struct load_cache_entries_thread_data *p = _data;
21642178
int i;
21652179

2180+
trace2_thread_start("load_cache_entries");
2181+
21662182
/* iterate across all ieot blocks assigned to this thread */
21672183
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21682184
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21692185
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21702186
p->offset += p->ieot->entries[i].nr;
21712187
}
2188+
2189+
trace2_thread_exit();
2190+
21722191
return NULL;
21732192
}
21742193

@@ -2321,7 +2340,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
23212340
int err;
23222341

23232342
p.src_offset = extension_offset;
2324-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2343+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
23252344
if (err)
23262345
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
23272346

@@ -3018,9 +3037,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30183037
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
30193038
struct strbuf sb = STRBUF_INIT;
30203039

3040+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30213041
cache_tree_write(&sb, istate->cache_tree);
30223042
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
30233043
hashwrite(f, sb.buf, sb.len);
3044+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3045+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3046+
30243047
strbuf_release(&sb);
30253048
if (err)
30263049
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)