Skip to content

Commit 57439ea

Browse files
jeffhostetlervdye
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 1caf76f + 1d51959 commit 57439ea

15 files changed

+241
-18
lines changed

builtin/checkout.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "merge-recursive.h"
2020
#include "object-name.h"
2121
#include "object-store.h"
22+
#include "packfile.h"
2223
#include "parse-options.h"
2324
#include "refs.h"
2425
#include "remote.h"
@@ -1015,8 +1016,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
10151016
remove_branch_state(the_repository, !opts->quiet);
10161017
strbuf_release(&msg);
10171018
if (!opts->quiet &&
1018-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
1019+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
1020+
unsigned long nr_unpack_entry_at_start;
1021+
1022+
trace2_region_enter("tracking", "report_tracking", the_repository);
1023+
nr_unpack_entry_at_start = get_nr_unpack_entry();
10191024
report_tracking(new_branch_info);
1025+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
1026+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
1027+
trace2_region_leave("tracking", "report_tracking", the_repository);
1028+
}
10201029
}
10211030

10221031
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
@@ -176,6 +176,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
176176
static int do_serialize = 0;
177177
static char *serialize_path = NULL;
178178

179+
static int reject_implicit = 0;
179180
static int do_implicit_deserialize = 0;
180181
static int do_explicit_deserialize = 0;
181182
static char *deserialize_path = NULL;
@@ -239,7 +240,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
239240
}
240241
if (!deserialize_path || !*deserialize_path)
241242
do_explicit_deserialize = 1; /* read stdin */
242-
else if (access(deserialize_path, R_OK) == 0)
243+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
243244
do_explicit_deserialize = 1; /* can read from this file */
244245
else {
245246
/*
@@ -1587,6 +1588,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
15871588
if (v && *v && access(v, R_OK) == 0) {
15881589
do_implicit_deserialize = 1;
15891590
deserialize_path = xstrdup(v);
1591+
} else {
1592+
reject_implicit = 1;
15901593
}
15911594
return 0;
15921595
}
@@ -1741,6 +1744,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17411744

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

17451759
enable_fscache(0);
17461760
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1784,6 +1798,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17841798
if (s.relative_paths)
17851799
s.prefix = prefix;
17861800

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

1819+
trace2_cmd_mode("collect");
18041820
wt_status_collect(&s);
18051821

18061822
if (0 <= fd)
@@ -1815,6 +1831,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18151831
if (fd_serialize < 0)
18161832
die_errno(_("could not serialize to '%s'"),
18171833
serialize_path);
1834+
trace2_cmd_mode("serialize");
18181835
wt_status_serialize_v1(fd_serialize, &s);
18191836
close(fd_serialize);
18201837
}

cache-tree.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,15 @@ static void discard_unused_subtrees(struct cache_tree *it)
231231
}
232232
}
233233

234-
int cache_tree_fully_valid(struct cache_tree *it)
234+
static int cache_tree_fully_valid_1(struct cache_tree *it)
235235
{
236236
int i;
237237
if (!it)
238238
return 0;
239239
if (it->entry_count < 0 || !repo_has_object_file(the_repository, &it->oid))
240240
return 0;
241241
for (i = 0; i < it->subtree_nr; i++) {
242-
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
242+
if (!cache_tree_fully_valid_1(it->down[i]->cache_tree))
243243
return 0;
244244
}
245245
return 1;
@@ -250,6 +250,17 @@ static int must_check_existence(const struct cache_entry *ce)
250250
return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
251251
}
252252

253+
int cache_tree_fully_valid(struct cache_tree *it)
254+
{
255+
int result;
256+
257+
trace2_region_enter("cache_tree", "fully_valid", NULL);
258+
result = cache_tree_fully_valid_1(it);
259+
trace2_region_leave("cache_tree", "fully_valid", NULL);
260+
261+
return result;
262+
}
263+
253264
static int update_one(struct cache_tree *it,
254265
struct cache_entry **cache,
255266
int entries,

compat/mingw.c

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

40044004
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
40054005

4006+
trace2_initialize_clock();
4007+
40064008
maybe_redirect_std_handles();
40074009
adjust_symlink_flags();
40084010
fsync_object_files = 1;

object-file.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "fsck.h"
4646
#include "wrapper.h"
4747
#include "trace.h"
48+
#include "trace2.h"
4849
#include "hook.h"
4950
#include "sigchain.h"
5051
#include "sub-process.h"
@@ -1000,6 +1001,8 @@ static int read_object_process(const struct object_id *oid)
10001001

10011002
start = getnanotime();
10021003

1004+
trace2_region_enter("subprocess", "read_object", the_repository);
1005+
10031006
if (!subprocess_map_initialized) {
10041007
subprocess_map_initialized = 1;
10051008
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -1016,13 +1019,16 @@ static int read_object_process(const struct object_id *oid)
10161019
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
10171020
start_read_object_fn)) {
10181021
free(entry);
1019-
return -1;
1022+
err = -1;
1023+
goto leave_region;
10201024
}
10211025
}
10221026
process = &entry->subprocess.process;
10231027

1024-
if (!(CAP_GET & entry->supported_capabilities))
1025-
return -1;
1028+
if (!(CAP_GET & entry->supported_capabilities)) {
1029+
err = -1;
1030+
goto leave_region;
1031+
}
10261032

10271033
sigchain_push(SIGPIPE, SIG_IGN);
10281034

@@ -1071,6 +1077,10 @@ static int read_object_process(const struct object_id *oid)
10711077

10721078
trace_performance_since(start, "read_object_process");
10731079

1080+
leave_region:
1081+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
1082+
"result %d", err);
1083+
10741084
return err;
10751085
}
10761086

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,13 @@ struct unpack_entry_stack_ent {
16681668
unsigned long size;
16691669
};
16701670

1671+
static unsigned long g_nr_unpack_entry;
1672+
1673+
unsigned long get_nr_unpack_entry(void)
1674+
{
1675+
return g_nr_unpack_entry;
1676+
}
1677+
16711678
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16721679
enum object_type *final_type, unsigned long *final_size)
16731680
{
@@ -1681,6 +1688,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16811688
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16821689
int base_from_cache = 0;
16831690

1691+
g_nr_unpack_entry++;
1692+
16841693
write_pack_access_log(p, obj_offset);
16851694

16861695
/* 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
@@ -208,4 +208,9 @@ int is_promisor_object(const struct object_id *oid);
208208
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
209209
size_t idx_size, struct packed_git *p);
210210

211+
/*
212+
* Return the number of objects fetched from a packfile.
213+
*/
214+
unsigned long get_nr_unpack_entry(void);
215+
211216
#endif

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,10 @@ static int read_index_extension(struct index_state *istate,
18181818
{
18191819
switch (CACHE_EXT(ext)) {
18201820
case CACHE_EXT_TREE:
1821+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
18211822
istate->cache_tree = cache_tree_read(data, sz);
1823+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1824+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
18221825
break;
18231826
case CACHE_EXT_RESOLVE_UNDO:
18241827
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2107,6 +2110,17 @@ static void *load_index_extensions(void *_data)
21072110
return NULL;
21082111
}
21092112

2113+
static void *load_index_extensions_threadproc(void *_data)
2114+
{
2115+
void *result;
2116+
2117+
trace2_thread_start("load_index_extensions");
2118+
result = load_index_extensions(_data);
2119+
trace2_thread_exit();
2120+
2121+
return result;
2122+
}
2123+
21102124
/*
21112125
* A helper function that will load the specified range of cache entries
21122126
* from the memory mapped file and add them to the given index.
@@ -2183,12 +2197,17 @@ static void *load_cache_entries_thread(void *_data)
21832197
struct load_cache_entries_thread_data *p = _data;
21842198
int i;
21852199

2200+
trace2_thread_start("load_cache_entries");
2201+
21862202
/* iterate across all ieot blocks assigned to this thread */
21872203
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21882204
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21892205
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21902206
p->offset += p->ieot->entries[i].nr;
21912207
}
2208+
2209+
trace2_thread_exit();
2210+
21922211
return NULL;
21932212
}
21942213

@@ -2355,7 +2374,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
23552374
int err;
23562375

23572376
p.src_offset = extension_offset;
2358-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2377+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
23592378
if (err)
23602379
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
23612380

@@ -3081,9 +3100,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30813100
!drop_cache_tree && istate->cache_tree) {
30823101
struct strbuf sb = STRBUF_INIT;
30833102

3103+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30843104
cache_tree_write(&sb, istate->cache_tree);
30853105
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
30863106
hashwrite(f, sb.buf, sb.len);
3107+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3108+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3109+
30873110
strbuf_release(&sb);
30883111
if (err)
30893112
return -1;

remote.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "setup.h"
2020
#include "string-list.h"
2121
#include "strvec.h"
22+
#include "trace2.h"
2223
#include "commit-reach.h"
2324
#include "advice.h"
2425
#include "connect.h"
@@ -2264,7 +2265,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
22642265
char *base;
22652266
int upstream_is_gone = 0;
22662267

2268+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
22672269
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2270+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2271+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2272+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2273+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2274+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2275+
}
2276+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2277+
22682278
if (sti < 0) {
22692279
if (!full_base)
22702280
return 0;

trace2/tr2_tgt_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static struct tr2_dst tr2dst_event = {
3737
* event target. Use the TR2_SYSENV_EVENT_NESTING setting to increase
3838
* region details in the event target.
3939
*/
40-
static int tr2env_event_max_nesting_levels = 2;
40+
static int tr2env_event_max_nesting_levels = 4;
4141

4242
/*
4343
* Use the TR2_SYSENV_EVENT_BRIEF to omit the <time>, <file>, and

0 commit comments

Comments
 (0)