Skip to content

Commit c12eb3f

Browse files
jeffhostetlerdscho
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 0c158e3 + 1734a7b commit c12eb3f

15 files changed

+242
-18
lines changed

builtin/checkout.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "merge-recursive.h"
1818
#include "object-name.h"
1919
#include "object-store-ll.h"
20+
#include "packfile.h"
2021
#include "parse-options.h"
2122
#include "path.h"
2223
#include "preload-index.h"
@@ -1043,8 +1044,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
10431044
strbuf_release(&msg);
10441045
if (!opts->quiet &&
10451046
!opts->force_detach &&
1046-
(new_branch_info->path || !strcmp(new_branch_info->name, "HEAD")))
1047+
(new_branch_info->path || !strcmp(new_branch_info->name, "HEAD"))) {
1048+
unsigned long nr_unpack_entry_at_start;
1049+
1050+
trace2_region_enter("tracking", "report_tracking", the_repository);
1051+
nr_unpack_entry_at_start = get_nr_unpack_entry();
10471052
report_tracking(new_branch_info);
1053+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
1054+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
1055+
trace2_region_leave("tracking", "report_tracking", the_repository);
1056+
}
10481057
}
10491058

10501059
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
@@ -164,6 +164,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
164164
static int do_serialize = 0;
165165
static char *serialize_path = NULL;
166166

167+
static int reject_implicit = 0;
167168
static int do_implicit_deserialize = 0;
168169
static int do_explicit_deserialize = 0;
169170
static char *deserialize_path = NULL;
@@ -227,7 +228,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
227228
}
228229
if (!deserialize_path || !*deserialize_path)
229230
do_explicit_deserialize = 1; /* read stdin */
230-
else if (access(deserialize_path, R_OK) == 0)
231+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
231232
do_explicit_deserialize = 1; /* can read from this file */
232233
else {
233234
/*
@@ -1597,6 +1598,8 @@ static int git_status_config(const char *k, const char *v,
15971598
if (v && *v && access(v, R_OK) == 0) {
15981599
do_implicit_deserialize = 1;
15991600
deserialize_path = xstrdup(v);
1601+
} else {
1602+
reject_implicit = 1;
16001603
}
16011604
return 0;
16021605
}
@@ -1747,6 +1750,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17471750

17481751
if (try_deserialize)
17491752
goto skip_init;
1753+
/*
1754+
* If we implicitly received a status cache pathname from the config
1755+
* and the file does not exist, we silently reject it and do the normal
1756+
* status "collect". Fake up some trace2 messages to reflect this and
1757+
* assist post-processors know this case is different.
1758+
*/
1759+
if (!do_serialize && reject_implicit) {
1760+
trace2_cmd_mode("implicit-deserialize");
1761+
trace2_data_string("status", the_repository, "deserialize/reject",
1762+
"status-cache/access");
1763+
}
17501764

17511765
enable_fscache(0);
17521766
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1790,6 +1804,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17901804
if (s.relative_paths)
17911805
s.prefix = prefix;
17921806

1807+
trace2_cmd_mode("deserialize");
17931808
result = wt_status_deserialize(&s, deserialize_path, dw);
17941809
if (result == DESERIALIZE_OK)
17951810
return 0;
@@ -1807,6 +1822,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18071822
fd = -1;
18081823
}
18091824

1825+
trace2_cmd_mode("collect");
18101826
wt_status_collect(&s);
18111827

18121828
if (0 <= fd)
@@ -1821,6 +1837,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18211837
if (fd_serialize < 0)
18221838
die_errno(_("could not serialize to '%s'"),
18231839
serialize_path);
1840+
trace2_cmd_mode("serialize");
18241841
wt_status_serialize_v1(fd_serialize, &s);
18251842
close(fd_serialize);
18261843
}

cache-tree.c

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

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

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

compat/mingw.c

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

40894089
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
40904090

4091+
trace2_initialize_clock();
4092+
40914093
maybe_redirect_std_handles();
40924094
adjust_symlink_flags();
40934095
fsync_object_files = 1;

object-file.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "loose.h"
4242
#include "object-file-convert.h"
4343
#include "trace.h"
44+
#include "trace2.h"
4445
#include "hook.h"
4546
#include "sigchain.h"
4647
#include "sub-process.h"
@@ -990,6 +991,8 @@ static int read_object_process(const struct object_id *oid)
990991

991992
start = getnanotime();
992993

994+
trace2_region_enter("subprocess", "read_object", the_repository);
995+
993996
if (!subprocess_map_initialized) {
994997
subprocess_map_initialized = 1;
995998
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -1006,13 +1009,16 @@ static int read_object_process(const struct object_id *oid)
10061009
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
10071010
start_read_object_fn)) {
10081011
free(entry);
1009-
return -1;
1012+
err = -1;
1013+
goto leave_region;
10101014
}
10111015
}
10121016
process = &entry->subprocess.process;
10131017

1014-
if (!(CAP_GET & entry->supported_capabilities))
1015-
return -1;
1018+
if (!(CAP_GET & entry->supported_capabilities)) {
1019+
err = -1;
1020+
goto leave_region;
1021+
}
10161022

10171023
sigchain_push(SIGPIPE, SIG_IGN);
10181024

@@ -1061,6 +1067,10 @@ static int read_object_process(const struct object_id *oid)
10611067

10621068
trace_performance_since(start, "read_object_process");
10631069

1070+
leave_region:
1071+
trace2_region_leave_printf("subprocess", "read_object", the_repository,
1072+
"result %d", err);
1073+
10641074
return err;
10651075
}
10661076

packfile.c

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

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

1690+
g_nr_unpack_entry++;
1691+
16831692
write_pack_access_log(p, obj_offset);
16841693

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

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

read-cache.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,10 @@ static int read_index_extension(struct index_state *istate,
17621762
{
17631763
switch (CACHE_EXT(ext)) {
17641764
case CACHE_EXT_TREE:
1765+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
17651766
istate->cache_tree = cache_tree_read(data, sz);
1767+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1768+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
17661769
break;
17671770
case CACHE_EXT_RESOLVE_UNDO:
17681771
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2052,6 +2055,17 @@ static void *load_index_extensions(void *_data)
20522055
return NULL;
20532056
}
20542057

2058+
static void *load_index_extensions_threadproc(void *_data)
2059+
{
2060+
void *result;
2061+
2062+
trace2_thread_start("load_index_extensions");
2063+
result = load_index_extensions(_data);
2064+
trace2_thread_exit();
2065+
2066+
return result;
2067+
}
2068+
20552069
/*
20562070
* A helper function that will load the specified range of cache entries
20572071
* from the memory mapped file and add them to the given index.
@@ -2128,12 +2142,17 @@ static void *load_cache_entries_thread(void *_data)
21282142
struct load_cache_entries_thread_data *p = _data;
21292143
int i;
21302144

2145+
trace2_thread_start("load_cache_entries");
2146+
21312147
/* iterate across all ieot blocks assigned to this thread */
21322148
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21332149
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21342150
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21352151
p->offset += p->ieot->entries[i].nr;
21362152
}
2153+
2154+
trace2_thread_exit();
2155+
21372156
return NULL;
21382157
}
21392158

@@ -2302,7 +2321,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
23022321
int err;
23032322

23042323
p.src_offset = extension_offset;
2305-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2324+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
23062325
if (err)
23072326
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
23082327

@@ -3030,9 +3049,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30303049
!drop_cache_tree && istate->cache_tree) {
30313050
struct strbuf sb = STRBUF_INIT;
30323051

3052+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30333053
cache_tree_write(&sb, istate->cache_tree);
30343054
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
30353055
hashwrite(f, sb.buf, sb.len);
3056+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3057+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3058+
30363059
strbuf_release(&sb);
30373060
if (err)
30383061
return -1;

remote.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "setup.h"
2121
#include "string-list.h"
2222
#include "strvec.h"
23+
#include "trace2.h"
2324
#include "commit-reach.h"
2425
#include "advice.h"
2526
#include "connect.h"
@@ -2288,7 +2289,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
22882289
char *base;
22892290
int upstream_is_gone = 0;
22902291

2292+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
22912293
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2294+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2295+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2296+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2297+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2298+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2299+
}
2300+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2301+
22922302
if (sti < 0) {
22932303
if (!full_base)
22942304
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)