diff options
author | Jeff Hostetler <jeffhost@microsoft.com> | 2022-10-24 15:41:06 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-10-24 21:45:26 +0200 |
commit | 8ad575646c0b1e927a05650a1ec64125121ae591 (patch) | |
tree | 17b2fb75a11ed67ca4490d59d10657c849efef38 /trace2/tr2_tls.h | |
parent | trace2: convert ctx.thread_name from strbuf to pointer (diff) | |
download | git-8ad575646c0b1e927a05650a1ec64125121ae591.tar.xz git-8ad575646c0b1e927a05650a1ec64125121ae591.zip |
trace2: add stopwatch timers
Add stopwatch timer mechanism to Trace2.
Timers are an alternative to Trace2 Regions. Regions are useful for
measuring the time spent in various computation phases, such as the
time to read the index, time to scan for unstaged files, time to scan
for untracked files, and etc.
However, regions are not appropriate in all places. For example,
during a checkout, it would be very inefficient to use regions to
measure the total time spent inflating objects from the ODB from
across the entire lifetime of the process; a per-unzip() region would
flood the output and significantly slow the command; and some form of
post-processing would be requried to compute the time spent in unzip().
Timers can be used to measure a series of timer intervals and emit
a single summary event (at thread and/or process exit).
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trace2/tr2_tls.h')
-rw-r--r-- | trace2/tr2_tls.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/trace2/tr2_tls.h b/trace2/tr2_tls.h index 65836b1399..a064b66e4c 100644 --- a/trace2/tr2_tls.h +++ b/trace2/tr2_tls.h @@ -2,6 +2,7 @@ #define TR2_TLS_H #include "strbuf.h" +#include "trace2/tr2_tmr.h" /* * Notice: the term "TLS" refers to "thread-local storage" in the @@ -20,6 +21,9 @@ struct tr2tls_thread_ctx { size_t alloc; size_t nr_open_regions; /* plays role of "nr" in ALLOC_GROW */ int thread_id; + struct tr2_timer_block timer_block; + unsigned int used_any_timer:1; + unsigned int used_any_per_thread_timer:1; }; /* @@ -107,4 +111,10 @@ int tr2tls_locked_increment(int *p); */ void tr2tls_start_process_clock(void); +/* + * Explicitly lock/unlock our mutex. + */ +void tr2tls_lock(void); +void tr2tls_unlock(void); + #endif /* TR2_TLS_H */ |