Skip to content

Commit 0ec8de1

Browse files
jeffhostetlerldennington
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 0a13891 + bcbf327 commit 0ec8de1

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"
@@ -964,8 +965,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
964965
remove_branch_state(the_repository, !opts->quiet);
965966
strbuf_release(&msg);
966967
if (!opts->quiet &&
967-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
968+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
969+
unsigned long nr_unpack_entry_at_start;
970+
971+
trace2_region_enter("tracking", "report_tracking", the_repository);
972+
nr_unpack_entry_at_start = get_nr_unpack_entry();
968973
report_tracking(new_branch_info);
974+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
975+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
976+
trace2_region_leave("tracking", "report_tracking", the_repository);
977+
}
969978
}
970979

971980
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
/*
@@ -1565,6 +1566,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
15651566
if (v && *v && access(v, R_OK) == 0) {
15661567
do_implicit_deserialize = 1;
15671568
deserialize_path = xstrdup(v);
1569+
} else {
1570+
reject_implicit = 1;
15681571
}
15691572
return 0;
15701573
}
@@ -1740,6 +1743,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17401743

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

17441758
enable_fscache(0);
17451759
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1783,6 +1797,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17831797
if (s.relative_paths)
17841798
s.prefix = prefix;
17851799

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

1818+
trace2_cmd_mode("collect");
18031819
wt_status_collect(&s);
18041820

18051821
if (0 <= fd)
@@ -1814,6 +1830,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18141830
if (fd_serialize < 0)
18151831
die_errno(_("could not serialize to '%s'"),
18161832
serialize_path);
1833+
trace2_cmd_mode("serialize");
18171834
wt_status_serialize_v1(fd_serialize, &s);
18181835
close(fd_serialize);
18191836
}

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,
@@ -836,14 +847,14 @@ void prime_cache_tree(struct repository *r,
836847
{
837848
struct strbuf tree_path = STRBUF_INIT;
838849

839-
trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
850+
trace2_region_enter("cache-tree", "prime_cache_tree", r);
840851
cache_tree_free(&istate->cache_tree);
841852
istate->cache_tree = cache_tree();
842853

843854
prime_cache_tree_rec(r, istate->cache_tree, tree, &tree_path);
844855
strbuf_release(&tree_path);
845856
istate->cache_changed |= CACHE_TREE_CHANGED;
846-
trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
857+
trace2_region_leave("cache-tree", "prime_cache_tree", r);
847858
}
848859

849860
/*

compat/mingw.c

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

37623762
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
37633763

3764+
trace2_initialize_clock();
3765+
37643766
maybe_redirect_std_handles();
37653767
adjust_symlink_flags();
37663768
fsync_object_files = FSYNC_OBJECT_FILES_ON;

object-file.c

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

977977
start = getnanotime();
978978

979+
trace2_region_enter("subprocess", "read_object", the_repository);
980+
979981
if (!subprocess_map_initialized) {
980982
subprocess_map_initialized = 1;
981983
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -992,13 +994,16 @@ static int read_object_process(const struct object_id *oid)
992994
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
993995
start_read_object_fn)) {
994996
free(entry);
995-
return -1;
997+
err = -1;
998+
goto leave_region;
996999
}
9971000
}
9981001
process = &entry->subprocess.process;
9991002

1000-
if (!(CAP_GET & entry->supported_capabilities))
1001-
return -1;
1003+
if (!(CAP_GET & entry->supported_capabilities)) {
1004+
err = -1;
1005+
goto leave_region;
1006+
}
10021007

10031008
sigchain_push(SIGPIPE, SIG_IGN);
10041009

@@ -1047,6 +1052,10 @@ static int read_object_process(const struct object_id *oid)
10471052

10481053
trace_performance_since(start, "read_object_process");
10491054

1055+
leave_region:
1056+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
1057+
"result %d", err);
1058+
10501059
return err;
10511060
}
10521061

packfile.c

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

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

1686+
g_nr_unpack_entry++;
1687+
16791688
write_pack_access_log(p, obj_offset);
16801689

16811690
/* 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
@@ -195,4 +195,9 @@ int is_promisor_object(const struct object_id *oid);
195195
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
196196
size_t idx_size, struct packed_git *p);
197197

198+
/*
199+
* Return the number of objects fetched from a packfile.
200+
*/
201+
unsigned long get_nr_unpack_entry(void);
202+
198203
#endif

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,10 @@ static int read_index_extension(struct index_state *istate,
18321832
{
18331833
switch (CACHE_EXT(ext)) {
18341834
case CACHE_EXT_TREE:
1835+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
18351836
istate->cache_tree = cache_tree_read(data, sz);
1837+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1838+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
18361839
break;
18371840
case CACHE_EXT_RESOLVE_UNDO:
18381841
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2100,6 +2103,17 @@ static void *load_index_extensions(void *_data)
21002103
return NULL;
21012104
}
21022105

2106+
static void *load_index_extensions_threadproc(void *_data)
2107+
{
2108+
void *result;
2109+
2110+
trace2_thread_start("load_index_extensions");
2111+
result = load_index_extensions(_data);
2112+
trace2_thread_exit();
2113+
2114+
return result;
2115+
}
2116+
21032117
/*
21042118
* A helper function that will load the specified range of cache entries
21052119
* from the memory mapped file and add them to the given index.
@@ -2176,12 +2190,17 @@ static void *load_cache_entries_thread(void *_data)
21762190
struct load_cache_entries_thread_data *p = _data;
21772191
int i;
21782192

2193+
trace2_thread_start("load_cache_entries");
2194+
21792195
/* iterate across all ieot blocks assigned to this thread */
21802196
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21812197
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21822198
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21832199
p->offset += p->ieot->entries[i].nr;
21842200
}
2201+
2202+
trace2_thread_exit();
2203+
21852204
return NULL;
21862205
}
21872206

@@ -2334,7 +2353,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
23342353
int err;
23352354

23362355
p.src_offset = extension_offset;
2337-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2356+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
23382357
if (err)
23392358
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
23402359

@@ -3042,9 +3061,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30423061
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
30433062
struct strbuf sb = STRBUF_INIT;
30443063

3064+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30453065
cache_tree_write(&sb, istate->cache_tree);
30463066
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
30473067
hashwrite(f, sb.buf, sb.len);
3068+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3069+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3070+
30483071
strbuf_release(&sb);
30493072
if (err)
30503073
return -1;

remote.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
22232223
char *base;
22242224
int upstream_is_gone = 0;
22252225

2226+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
22262227
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2228+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2229+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2230+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2231+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2232+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2233+
}
2234+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2235+
22272236
if (sti < 0) {
22282237
if (!full_base)
22292238
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)