Skip to content

Commit 716ccc7

Browse files
jeffhostetlerderrickstolee
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 f5756a6 + e06d68b commit 716ccc7

15 files changed

+240
-16
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>"),
@@ -931,8 +932,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
931932
remove_branch_state(the_repository, !opts->quiet);
932933
strbuf_release(&msg);
933934
if (!opts->quiet &&
934-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
935+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
936+
unsigned long nr_unpack_entry_at_start;
937+
938+
trace2_region_enter("tracking", "report_tracking", the_repository);
939+
nr_unpack_entry_at_start = get_nr_unpack_entry();
935940
report_tracking(new_branch_info);
941+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
942+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
943+
trace2_region_leave("tracking", "report_tracking", the_repository);
944+
}
936945
}
937946

938947
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
/*
@@ -1447,6 +1448,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
14471448
if (v && *v && access(v, R_OK) == 0) {
14481449
do_implicit_deserialize = 1;
14491450
deserialize_path = xstrdup(v);
1451+
} else {
1452+
reject_implicit = 1;
14501453
}
14511454
return 0;
14521455
}
@@ -1619,6 +1622,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16191622

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

16231637
enable_fscache(0);
16241638
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1662,6 +1676,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16621676
if (s.relative_paths)
16631677
s.prefix = prefix;
16641678

1679+
trace2_cmd_mode("deserialize");
16651680
result = wt_status_deserialize(&s, deserialize_path, dw);
16661681
if (result == DESERIALIZE_OK)
16671682
return 0;
@@ -1679,6 +1694,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16791694
fd = -1;
16801695
}
16811696

1697+
trace2_cmd_mode("collect");
16821698
wt_status_collect(&s);
16831699

16841700
if (0 <= fd)
@@ -1693,6 +1709,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16931709
if (fd_serialize < 0)
16941710
die_errno(_("could not serialize to '%s'"),
16951711
serialize_path);
1712+
trace2_cmd_mode("serialize");
16961713
wt_status_serialize_v1(fd_serialize, &s);
16971714
close(fd_serialize);
16981715
}

cache-tree.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,31 @@ static void discard_unused_subtrees(struct cache_tree *it)
222222
}
223223
}
224224

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

239+
int cache_tree_fully_valid(struct cache_tree *it)
240+
{
241+
int result;
242+
243+
trace2_region_enter("cache_tree", "fully_valid", NULL);
244+
result = cache_tree_fully_valid_1(it);
245+
trace2_region_leave("cache_tree", "fully_valid", NULL);
246+
247+
return result;
248+
}
249+
239250
static int update_one(struct cache_tree *it,
240251
struct cache_entry **cache,
241252
int entries,
@@ -757,10 +768,14 @@ void prime_cache_tree(struct repository *r,
757768
struct index_state *istate,
758769
struct tree *tree)
759770
{
771+
trace2_region_enter("cache_tree", "prime_cache_tree", r);
772+
760773
cache_tree_free(&istate->cache_tree);
761774
istate->cache_tree = cache_tree();
762775
prime_cache_tree_rec(r, istate->cache_tree, tree);
763776
istate->cache_changed |= CACHE_TREE_CHANGED;
777+
778+
trace2_region_leave("cache_tree", "prime_cache_tree", r);
764779
}
765780

766781
/*

compat/mingw.c

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

37133713
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
37143714

3715+
trace2_initialize_clock();
3716+
37153717
maybe_redirect_std_handles();
37163718
adjust_symlink_flags();
37173719
fsync_object_files = 1;

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,13 @@ static void *read_object(struct repository *r,
16561656
return content;
16571657
}
16581658

1659+
static unsigned long g_nr_unpack_entry;
1660+
1661+
unsigned long get_nr_unpack_entry(void)
1662+
{
1663+
return g_nr_unpack_entry;
1664+
}
1665+
16591666
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16601667
enum object_type *final_type, unsigned long *final_size)
16611668
{
@@ -1669,6 +1676,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16691676
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16701677
int base_from_cache = 0;
16711678

1679+
g_nr_unpack_entry++;
1680+
16721681
write_pack_access_log(p, obj_offset);
16731682

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

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

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,10 @@ static int read_index_extension(struct index_state *istate,
17501750
{
17511751
switch (CACHE_EXT(ext)) {
17521752
case CACHE_EXT_TREE:
1753+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
17531754
istate->cache_tree = cache_tree_read(data, sz);
1755+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1756+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
17541757
break;
17551758
case CACHE_EXT_RESOLVE_UNDO:
17561759
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2005,6 +2008,17 @@ static void *load_index_extensions(void *_data)
20052008
return NULL;
20062009
}
20072010

2011+
static void *load_index_extensions_threadproc(void *_data)
2012+
{
2013+
void *result;
2014+
2015+
trace2_thread_start("load_index_extensions");
2016+
result = load_index_extensions(_data);
2017+
trace2_thread_exit();
2018+
2019+
return result;
2020+
}
2021+
20082022
/*
20092023
* A helper function that will load the specified range of cache entries
20102024
* from the memory mapped file and add them to the given index.
@@ -2080,12 +2094,17 @@ static void *load_cache_entries_thread(void *_data)
20802094
struct load_cache_entries_thread_data *p = _data;
20812095
int i;
20822096

2097+
trace2_thread_start("load_cache_entries");
2098+
20832099
/* iterate across all ieot blocks assigned to this thread */
20842100
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
20852101
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
20862102
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
20872103
p->offset += p->ieot->entries[i].nr;
20882104
}
2105+
2106+
trace2_thread_exit();
2107+
20892108
return NULL;
20902109
}
20912110

@@ -2235,7 +2254,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
22352254
int err;
22362255

22372256
p.src_offset = extension_offset;
2238-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2257+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
22392258
if (err)
22402259
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
22412260

@@ -2983,9 +3002,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
29833002
if (!strip_extensions && !drop_cache_tree && istate->cache_tree) {
29843003
struct strbuf sb = STRBUF_INIT;
29853004

3005+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
29863006
cache_tree_write(&sb, istate->cache_tree);
29873007
err = write_index_ext_header(&c, &eoie_c, newfd, CACHE_EXT_TREE, sb.len) < 0
29883008
|| ce_write(&c, newfd, sb.buf, sb.len) < 0;
3009+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3010+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3011+
29893012
strbuf_release(&sb);
29903013
if (err)
29913014
return -1;

remote.c

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

1992+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
19921993
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
1994+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
1995+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
1996+
if (abf == AHEAD_BEHIND_FULL) {
1997+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
1998+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
1999+
}
2000+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2001+
19932002
if (sti < 0) {
19942003
if (!full_base)
19952004
return 0;

sha1-file.c

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

917917
start = getnanotime();
918918

919+
trace2_region_enter("subprocess", "read_object", the_repository);
920+
919921
if (!subprocess_map_initialized) {
920922
subprocess_map_initialized = 1;
921923
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -932,13 +934,16 @@ static int read_object_process(const struct object_id *oid)
932934
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
933935
start_read_object_fn)) {
934936
free(entry);
935-
return -1;
937+
err = -1;
938+
goto leave_region;
936939
}
937940
}
938941
process = &entry->subprocess.process;
939942

940-
if (!(CAP_GET & entry->supported_capabilities))
941-
return -1;
943+
if (!(CAP_GET & entry->supported_capabilities)) {
944+
err = -1;
945+
goto leave_region;
946+
}
942947

943948
sigchain_push(SIGPIPE, SIG_IGN);
944949

@@ -987,6 +992,10 @@ static int read_object_process(const struct object_id *oid)
987992

988993
trace_performance_since(start, "read_object_process");
989994

995+
leave_region:
996+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
997+
"result %d", err);
998+
990999
return err;
9911000
}
9921001

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)