Skip to content

Commit 471cbef

Browse files
committed
Merge trace2 experimental regions
Includes gvfs-specific commits from these pull requests: git-for-windows#158 git-for-windows#159 git-for-windows#160 git-for-windows#164 Signed-off-by: Derrick Stolee <[email protected]>
2 parents df35772 + b77cb78 commit 471cbef

15 files changed

+238
-20
lines changed

builtin/checkout.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "unpack-trees.h"
2727
#include "wt-status.h"
2828
#include "xdiff-interface.h"
29+
#include "packfile.h"
2930

3031
static const char * const checkout_usage[] = {
3132
N_("git checkout [<options>] <branch>"),
@@ -937,8 +938,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
937938
remove_branch_state(the_repository, !opts->quiet);
938939
strbuf_release(&msg);
939940
if (!opts->quiet &&
940-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
941+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
942+
unsigned long nr_unpack_entry_at_start;
943+
944+
trace2_region_enter("tracking", "report_tracking", the_repository);
945+
nr_unpack_entry_at_start = get_nr_unpack_entry();
941946
report_tracking(new_branch_info);
947+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
948+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
949+
trace2_region_leave("tracking", "report_tracking", the_repository);
950+
}
942951
}
943952

944953
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
@@ -151,6 +151,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
151151
static int do_serialize = 0;
152152
static char *serialize_path = NULL;
153153

154+
static int reject_implicit = 0;
154155
static int do_implicit_deserialize = 0;
155156
static int do_explicit_deserialize = 0;
156157
static char *deserialize_path = NULL;
@@ -214,7 +215,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
214215
}
215216
if (!deserialize_path || !*deserialize_path)
216217
do_explicit_deserialize = 1; /* read stdin */
217-
else if (access(deserialize_path, R_OK) == 0)
218+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
218219
do_explicit_deserialize = 1; /* can read from this file */
219220
else {
220221
/*
@@ -1445,6 +1446,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
14451446
if (v && *v && access(v, R_OK) == 0) {
14461447
do_implicit_deserialize = 1;
14471448
deserialize_path = xstrdup(v);
1449+
} else {
1450+
reject_implicit = 1;
14481451
}
14491452
return 0;
14501453
}
@@ -1617,6 +1620,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16171620

16181621
if (try_deserialize)
16191622
goto skip_init;
1623+
/*
1624+
* If we implicitly received a status cache pathname from the config
1625+
* and the file does not exist, we silently reject it and do the normal
1626+
* status "collect". Fake up some trace2 messages to reflect this and
1627+
* assist post-processors know this case is different.
1628+
*/
1629+
if (!do_serialize && reject_implicit) {
1630+
trace2_cmd_mode("implicit-deserialize");
1631+
trace2_data_string("status", the_repository, "deserialize/reject",
1632+
"status-cache/access");
1633+
}
16201634

16211635
enable_fscache(0);
16221636
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1660,6 +1674,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16601674
if (s.relative_paths)
16611675
s.prefix = prefix;
16621676

1677+
trace2_cmd_mode("deserialize");
16631678
result = wt_status_deserialize(&s, deserialize_path, dw);
16641679
if (result == DESERIALIZE_OK)
16651680
return 0;
@@ -1677,6 +1692,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16771692
fd = -1;
16781693
}
16791694

1695+
trace2_cmd_mode("collect");
16801696
wt_status_collect(&s);
16811697

16821698
if (0 <= fd)
@@ -1691,6 +1707,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16911707
if (fd_serialize < 0)
16921708
die_errno(_("could not serialize to '%s'"),
16931709
serialize_path);
1710+
trace2_cmd_mode("serialize");
16941711
wt_status_serialize_v1(fd_serialize, &s);
16951712
close(fd_serialize);
16961713
}

cache-tree.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,31 @@ static void discard_unused_subtrees(struct cache_tree *it)
223223
}
224224
}
225225

226-
int cache_tree_fully_valid(struct cache_tree *it)
226+
static int cache_tree_fully_valid_1(struct cache_tree *it)
227227
{
228228
int i;
229229
if (!it)
230230
return 0;
231231
if (it->entry_count < 0 || !has_object_file(&it->oid))
232232
return 0;
233233
for (i = 0; i < it->subtree_nr; i++) {
234-
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
234+
if (!cache_tree_fully_valid_1(it->down[i]->cache_tree))
235235
return 0;
236236
}
237237
return 1;
238238
}
239239

240+
int cache_tree_fully_valid(struct cache_tree *it)
241+
{
242+
int result;
243+
244+
trace2_region_enter("cache_tree", "fully_valid", NULL);
245+
result = cache_tree_fully_valid_1(it);
246+
trace2_region_leave("cache_tree", "fully_valid", NULL);
247+
248+
return result;
249+
}
250+
240251
static int update_one(struct cache_tree *it,
241252
struct cache_entry **cache,
242253
int entries,
@@ -770,13 +781,13 @@ void prime_cache_tree(struct repository *r,
770781
struct index_state *istate,
771782
struct tree *tree)
772783
{
773-
trace2_region_enter("cache-tree", "prime_cache_tree", the_repository);
784+
trace2_region_enter("cache-tree", "prime_cache_tree", r);
774785
cache_tree_free(&istate->cache_tree);
775786
istate->cache_tree = cache_tree();
776787

777788
prime_cache_tree_rec(r, istate->cache_tree, tree);
778789
istate->cache_changed |= CACHE_TREE_CHANGED;
779-
trace2_region_leave("cache-tree", "prime_cache_tree", the_repository);
790+
trace2_region_leave("cache-tree", "prime_cache_tree", r);
780791
}
781792

782793
/*

compat/mingw.c

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

37283728
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
37293729

3730+
trace2_initialize_clock();
3731+
37303732
maybe_redirect_std_handles();
37313733
adjust_symlink_flags();
37323734
fsync_object_files = 1;

object-file.c

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

927927
start = getnanotime();
928928

929+
trace2_region_enter("subprocess", "read_object", the_repository);
930+
929931
if (!subprocess_map_initialized) {
930932
subprocess_map_initialized = 1;
931933
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -942,13 +944,16 @@ static int read_object_process(const struct object_id *oid)
942944
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
943945
start_read_object_fn)) {
944946
free(entry);
945-
return -1;
947+
err = -1;
948+
goto leave_region;
946949
}
947950
}
948951
process = &entry->subprocess.process;
949952

950-
if (!(CAP_GET & entry->supported_capabilities))
951-
return -1;
953+
if (!(CAP_GET & entry->supported_capabilities)) {
954+
err = -1;
955+
goto leave_region;
956+
}
952957

953958
sigchain_push(SIGPIPE, SIG_IGN);
954959

@@ -997,6 +1002,10 @@ static int read_object_process(const struct object_id *oid)
9971002

9981003
trace_performance_since(start, "read_object_process");
9991004

1005+
leave_region:
1006+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
1007+
"result %d", err);
1008+
10001009
return err;
10011010
}
10021011

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,13 @@ static void *read_object(struct repository *r,
16731673
return content;
16741674
}
16751675

1676+
static unsigned long g_nr_unpack_entry;
1677+
1678+
unsigned long get_nr_unpack_entry(void)
1679+
{
1680+
return g_nr_unpack_entry;
1681+
}
1682+
16761683
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16771684
enum object_type *final_type, unsigned long *final_size)
16781685
{
@@ -1686,6 +1693,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16861693
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16871694
int base_from_cache = 0;
16881695

1696+
g_nr_unpack_entry++;
1697+
16891698
write_pack_access_log(p, obj_offset);
16901699

16911700
/* 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
@@ -191,4 +191,9 @@ int is_promisor_object(const struct object_id *oid);
191191
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
192192
size_t idx_size, struct packed_git *p);
193193

194+
/*
195+
* Return the number of objects fetched from a packfile.
196+
*/
197+
unsigned long get_nr_unpack_entry(void);
198+
194199
#endif

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,10 @@ static int read_index_extension(struct index_state *istate,
17561756
{
17571757
switch (CACHE_EXT(ext)) {
17581758
case CACHE_EXT_TREE:
1759+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
17591760
istate->cache_tree = cache_tree_read(data, sz);
1761+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1762+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
17601763
break;
17611764
case CACHE_EXT_RESOLVE_UNDO:
17621765
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2011,6 +2014,17 @@ static void *load_index_extensions(void *_data)
20112014
return NULL;
20122015
}
20132016

2017+
static void *load_index_extensions_threadproc(void *_data)
2018+
{
2019+
void *result;
2020+
2021+
trace2_thread_start("load_index_extensions");
2022+
result = load_index_extensions(_data);
2023+
trace2_thread_exit();
2024+
2025+
return result;
2026+
}
2027+
20142028
/*
20152029
* A helper function that will load the specified range of cache entries
20162030
* from the memory mapped file and add them to the given index.
@@ -2087,12 +2101,17 @@ static void *load_cache_entries_thread(void *_data)
20872101
struct load_cache_entries_thread_data *p = _data;
20882102
int i;
20892103

2104+
trace2_thread_start("load_cache_entries");
2105+
20902106
/* iterate across all ieot blocks assigned to this thread */
20912107
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
20922108
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
20932109
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
20942110
p->offset += p->ieot->entries[i].nr;
20952111
}
2112+
2113+
trace2_thread_exit();
2114+
20962115
return NULL;
20972116
}
20982117

@@ -2244,7 +2263,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22442263
int err;
22452264

22462265
p.src_offset = extension_offset;
2247-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2266+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
22482267
if (err)
22492268
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
22502269

@@ -2993,9 +3012,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
29933012
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
29943013
struct strbuf sb = STRBUF_INIT;
29953014

3015+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
29963016
cache_tree_write(&sb, istate->cache_tree);
29973017
err = write_index_ext_header(&c, &eoie_c, newfd, CACHE_EXT_TREE, sb.len) < 0
29983018
|| ce_write(&c, newfd, sb.buf, sb.len) < 0;
3019+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3020+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3021+
29993022
strbuf_release(&sb);
30003023
if (err)
30013024
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 (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)