diff options
author | Jeff Hostetler <jeffhost@microsoft.com> | 2022-10-24 16:41:07 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-10-24 22:45:26 +0300 |
commit | 81071626ba1ec54ad72de1e0a9a49c78eb87a2c8 (patch) | |
tree | 2b4b5244c2b6f5b24ff586680637b4a7b4f9c7b0 /trace2/tr2_tgt.h | |
parent | 8ad575646c0b1e927a05650a1ec64125121ae591 (diff) |
trace2: add global counter mechanism
Add global counters mechanism to Trace2.
The Trace2 counters mechanism adds the ability to create a set of
global counter variables and an API to increment them efficiently.
Counters can optionally report per-thread usage in addition to the sum
across all threads.
Counter events are emitted to the Trace2 logs when a thread exits and
at process exit.
Counters are an alternative to `data` and `data_json` events.
Counters are useful when you want to measure something across the life
of the process, when you don't want per-measurement events for
performance reasons, when the data does not fit conveniently within a
region, or when your control flow does not easily let you write the
final total. For example, you might use this to report the number of
calls to unzip() or the number of de-delta steps during a checkout.
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trace2/tr2_tgt.h')
-rw-r--r-- | trace2/tr2_tgt.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/trace2/tr2_tgt.h b/trace2/tr2_tgt.h index 85c8d2d7f5..bf8745c4f0 100644 --- a/trace2/tr2_tgt.h +++ b/trace2/tr2_tgt.h @@ -6,6 +6,8 @@ struct repository; struct json_writer; struct tr2_timer_metadata; struct tr2_timer; +struct tr2_counter_metadata; +struct tr2_counter; #define NS_TO_SEC(ns) ((double)(ns) / 1.0e9) @@ -104,6 +106,10 @@ typedef void(tr2_tgt_evt_timer_t)(const struct tr2_timer_metadata *meta, const struct tr2_timer *timer, int is_final_data); +typedef void(tr2_tgt_evt_counter_t)(const struct tr2_counter_metadata *meta, + const struct tr2_counter *counter, + int is_final_data); + /* * "vtable" for a TRACE2 target. Use NULL if a target does not want * to emit that message. @@ -141,6 +147,7 @@ struct tr2_tgt { tr2_tgt_evt_data_json_fl_t *pfn_data_json_fl; tr2_tgt_evt_printf_va_fl_t *pfn_printf_va_fl; tr2_tgt_evt_timer_t *pfn_timer; + tr2_tgt_evt_counter_t *pfn_counter; }; /* clang-format on */ |