Skip to content

Commit e6d6da6

Browse files
jeffhostetlervdye
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 d723539 + 41c5b12 commit e6d6da6

15 files changed

+240
-18
lines changed

builtin/checkout.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "merge-recursive.h"
1919
#include "object-name.h"
2020
#include "object-store-ll.h"
21+
#include "packfile.h"
2122
#include "parse-options.h"
2223
#include "path.h"
2324
#include "preload-index.h"
@@ -1022,8 +1023,16 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
10221023
remove_branch_state(the_repository, !opts->quiet);
10231024
strbuf_release(&msg);
10241025
if (!opts->quiet &&
1025-
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
1026+
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
1027+
unsigned long nr_unpack_entry_at_start;
1028+
1029+
trace2_region_enter("tracking", "report_tracking", the_repository);
1030+
nr_unpack_entry_at_start = get_nr_unpack_entry();
10261031
report_tracking(new_branch_info);
1032+
trace2_data_intmax("tracking", NULL, "report_tracking/nr_unpack_entries",
1033+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
1034+
trace2_region_leave("tracking", "report_tracking", the_repository);
1035+
}
10271036
}
10281037

10291038
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
@@ -171,6 +171,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
171171
static int do_serialize = 0;
172172
static char *serialize_path = NULL;
173173

174+
static int reject_implicit = 0;
174175
static int do_implicit_deserialize = 0;
175176
static int do_explicit_deserialize = 0;
176177
static char *deserialize_path = NULL;
@@ -234,7 +235,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
234235
}
235236
if (!deserialize_path || !*deserialize_path)
236237
do_explicit_deserialize = 1; /* read stdin */
237-
else if (access(deserialize_path, R_OK) == 0)
238+
else if (wt_status_deserialize_access(deserialize_path, R_OK) == 0)
238239
do_explicit_deserialize = 1; /* can read from this file */
239240
else {
240241
/*
@@ -1583,6 +1584,8 @@ static int git_status_config(const char *k, const char *v,
15831584
if (v && *v && access(v, R_OK) == 0) {
15841585
do_implicit_deserialize = 1;
15851586
deserialize_path = xstrdup(v);
1587+
} else {
1588+
reject_implicit = 1;
15861589
}
15871590
return 0;
15881591
}
@@ -1737,6 +1740,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17371740

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

17411755
enable_fscache(0);
17421756
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1780,6 +1794,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17801794
if (s.relative_paths)
17811795
s.prefix = prefix;
17821796

1797+
trace2_cmd_mode("deserialize");
17831798
result = wt_status_deserialize(&s, deserialize_path, dw);
17841799
if (result == DESERIALIZE_OK)
17851800
return 0;
@@ -1797,6 +1812,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
17971812
fd = -1;
17981813
}
17991814

1815+
trace2_cmd_mode("collect");
18001816
wt_status_collect(&s);
18011817

18021818
if (0 <= fd)
@@ -1811,6 +1827,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
18111827
if (fd_serialize < 0)
18121828
die_errno(_("could not serialize to '%s'"),
18131829
serialize_path);
1830+
trace2_cmd_mode("serialize");
18141831
wt_status_serialize_v1(fd_serialize, &s);
18151832
close(fd_serialize);
18161833
}

cache-tree.c

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

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

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

compat/mingw.c

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

40854085
SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
40864086

4087+
trace2_initialize_clock();
4088+
40874089
maybe_redirect_std_handles();
40884090
adjust_symlink_flags();
40894091
fsync_object_files = 1;

object-file.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "submodule.h"
3737
#include "fsck.h"
3838
#include "trace.h"
39+
#include "trace2.h"
3940
#include "hook.h"
4041
#include "sigchain.h"
4142
#include "sub-process.h"
@@ -991,6 +992,8 @@ static int read_object_process(const struct object_id *oid)
991992

992993
start = getnanotime();
993994

995+
trace2_region_enter("subprocess", "read_object", the_repository);
996+
994997
if (!subprocess_map_initialized) {
995998
subprocess_map_initialized = 1;
996999
hashmap_init(&subprocess_map, (hashmap_cmp_fn)cmd2process_cmp,
@@ -1007,13 +1010,16 @@ static int read_object_process(const struct object_id *oid)
10071010
if (subprocess_start(&subprocess_map, &entry->subprocess, cmd,
10081011
start_read_object_fn)) {
10091012
free(entry);
1010-
return -1;
1013+
err = -1;
1014+
goto leave_region;
10111015
}
10121016
}
10131017
process = &entry->subprocess.process;
10141018

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

10181024
sigchain_push(SIGPIPE, SIG_IGN);
10191025

@@ -1062,6 +1068,10 @@ static int read_object_process(const struct object_id *oid)
10621068

10631069
trace_performance_since(start, "read_object_process");
10641070

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

packfile.c

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

1668+
static unsigned long g_nr_unpack_entry;
1669+
1670+
unsigned long get_nr_unpack_entry(void)
1671+
{
1672+
return g_nr_unpack_entry;
1673+
}
1674+
16681675
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16691676
enum object_type *final_type, unsigned long *final_size)
16701677
{
@@ -1678,6 +1685,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16781685
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16791686
int base_from_cache = 0;
16801687

1688+
g_nr_unpack_entry++;
1689+
16811690
write_pack_access_log(p, obj_offset);
16821691

16831692
/* 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
@@ -1792,7 +1792,10 @@ static int read_index_extension(struct index_state *istate,
17921792
{
17931793
switch (CACHE_EXT(ext)) {
17941794
case CACHE_EXT_TREE:
1795+
trace2_region_enter("index", "read/extension/cache_tree", NULL);
17951796
istate->cache_tree = cache_tree_read(data, sz);
1797+
trace2_data_intmax("index", NULL, "read/extension/cache_tree/bytes", (intmax_t)sz);
1798+
trace2_region_leave("index", "read/extension/cache_tree", NULL);
17961799
break;
17971800
case CACHE_EXT_RESOLVE_UNDO:
17981801
istate->resolve_undo = resolve_undo_read(data, sz);
@@ -2081,6 +2084,17 @@ static void *load_index_extensions(void *_data)
20812084
return NULL;
20822085
}
20832086

2087+
static void *load_index_extensions_threadproc(void *_data)
2088+
{
2089+
void *result;
2090+
2091+
trace2_thread_start("load_index_extensions");
2092+
result = load_index_extensions(_data);
2093+
trace2_thread_exit();
2094+
2095+
return result;
2096+
}
2097+
20842098
/*
20852099
* A helper function that will load the specified range of cache entries
20862100
* from the memory mapped file and add them to the given index.
@@ -2157,12 +2171,17 @@ static void *load_cache_entries_thread(void *_data)
21572171
struct load_cache_entries_thread_data *p = _data;
21582172
int i;
21592173

2174+
trace2_thread_start("load_cache_entries");
2175+
21602176
/* iterate across all ieot blocks assigned to this thread */
21612177
for (i = p->ieot_start; i < p->ieot_start + p->ieot_blocks; i++) {
21622178
p->consumed += load_cache_entry_block(p->istate, p->ce_mem_pool,
21632179
p->offset, p->ieot->entries[i].nr, p->mmap, p->ieot->entries[i].offset, NULL);
21642180
p->offset += p->ieot->entries[i].nr;
21652181
}
2182+
2183+
trace2_thread_exit();
2184+
21662185
return NULL;
21672186
}
21682187

@@ -2330,7 +2349,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
23302349
int err;
23312350

23322351
p.src_offset = extension_offset;
2333-
err = pthread_create(&p.pthread, NULL, load_index_extensions, &p);
2352+
err = pthread_create(&p.pthread, NULL, load_index_extensions_threadproc, &p);
23342353
if (err)
23352354
die(_("unable to create load_index_extensions thread: %s"), strerror(err));
23362355

@@ -3058,9 +3077,13 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
30583077
!drop_cache_tree && istate->cache_tree) {
30593078
struct strbuf sb = STRBUF_INIT;
30603079

3080+
trace2_region_enter("index", "write/extension/cache_tree", NULL);
30613081
cache_tree_write(&sb, istate->cache_tree);
30623082
err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
30633083
hashwrite(f, sb.buf, sb.len);
3084+
trace2_data_intmax("index", NULL, "write/extension/cache_tree/bytes", (intmax_t)sb.len);
3085+
trace2_region_leave("index", "write/extension/cache_tree", NULL);
3086+
30643087
strbuf_release(&sb);
30653088
if (err)
30663089
return -1;

remote.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "setup.h"
1919
#include "string-list.h"
2020
#include "strvec.h"
21+
#include "trace2.h"
2122
#include "commit-reach.h"
2223
#include "advice.h"
2324
#include "connect.h"
@@ -2272,7 +2273,16 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
22722273
char *base;
22732274
int upstream_is_gone = 0;
22742275

2276+
trace2_region_enter("tracking", "stat_tracking_info", NULL);
22752277
sti = stat_tracking_info(branch, &ours, &theirs, &full_base, 0, abf);
2278+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_flags", abf);
2279+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_result", sti);
2280+
if (sti >= 0 && abf == AHEAD_BEHIND_FULL) {
2281+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_ahead", ours);
2282+
trace2_data_intmax("tracking", NULL, "stat_tracking_info/ab_behind", theirs);
2283+
}
2284+
trace2_region_leave("tracking", "stat_tracking_info", NULL);
2285+
22762286
if (sti < 0) {
22772287
if (!full_base)
22782288
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)