From: Mathieu Desnoyers Date: Fri, 9 Sep 2016 21:01:18 +0000 (-0400) Subject: Performance: disable event counting by default X-Git-Tag: v2.9.0-rc1~18 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=25337cb556cedb95ff65c1e91aab0dea6a3e77b4;p=lttng-modules.git Performance: disable event counting by default Performance improvement changelog from lttng-ust, ported back to lttng-modules: Disable event counting in the ring buffer, which can count the number of events produced per ring-buffer, as well as the number of events overwritten in overwrite mode. This feature is currently unused anyway: it is not saved in the ring buffer header, nor made available to lttng-tools. This saves 70 ns/event in lttng-ust on the ARM32 Cubietruck. Signed-off-by: Mathieu Desnoyers --- diff --git a/lib/ringbuffer/backend_internal.h b/lib/ringbuffer/backend_internal.h index 16001776..fc5bec53 100644 --- a/lib/ringbuffer/backend_internal.h +++ b/lib/ringbuffer/backend_internal.h @@ -201,6 +201,11 @@ int subbuffer_id_check_index(const struct lib_ring_buffer_config *config, return 0; } +/* + * The ring buffer can count events recorded and overwritten per buffer, + * but it is disabled by default due to its performance overhead. + */ +#ifdef LTTNG_RING_BUFFER_COUNT_EVENTS static inline void subbuffer_count_record(const struct lib_ring_buffer_config *config, struct lib_ring_buffer_backend *bufb, @@ -211,6 +216,14 @@ void subbuffer_count_record(const struct lib_ring_buffer_config *config, sb_bindex = subbuffer_id_get_index(config, bufb->buf_wsb[idx].id); v_inc(config, &bufb->array[sb_bindex]->records_commit); } +#else /* LTTNG_RING_BUFFER_COUNT_EVENTS */ +static inline +void subbuffer_count_record(const struct lib_ring_buffer_config *config, + struct lib_ring_buffer_backend *bufb, + unsigned long idx) +{ +} +#endif /* #else LTTNG_RING_BUFFER_COUNT_EVENTS */ /* * Reader has exclusive subbuffer access for record consumption. No need to diff --git a/lib/ringbuffer/ring_buffer_frontend.c b/lib/ringbuffer/ring_buffer_frontend.c index 6c990c25..9d13d292 100644 --- a/lib/ringbuffer/ring_buffer_frontend.c +++ b/lib/ringbuffer/ring_buffer_frontend.c @@ -1982,6 +1982,33 @@ void lib_ring_buffer_vmcore_check_deliver(const struct lib_ring_buffer_config *c v_set(config, &buf->commit_hot[idx].seq, commit_count); } +/* + * The ring buffer can count events recorded and overwritten per buffer, + * but it is disabled by default due to its performance overhead. + */ +#ifdef LTTNG_RING_BUFFER_COUNT_EVENTS +static +void deliver_count_events(const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *buf, + unsigned long idx) +{ + v_add(config, subbuffer_get_records_count(config, + &buf->backend, idx), + &buf->records_count); + v_add(config, subbuffer_count_records_overrun(config, + &buf->backend, idx), + &buf->records_overrun); +} +#else /* LTTNG_RING_BUFFER_COUNT_EVENTS */ +static +void deliver_count_events(const struct lib_ring_buffer_config *config, + struct lib_ring_buffer *buf, + unsigned long idx) +{ +} +#endif /* #else LTTNG_RING_BUFFER_COUNT_EVENTS */ + + void lib_ring_buffer_check_deliver_slow(const struct lib_ring_buffer_config *config, struct lib_ring_buffer *buf, struct channel *chan, @@ -2034,15 +2061,7 @@ void lib_ring_buffer_check_deliver_slow(const struct lib_ring_buffer_config *con * and any other writer trying to access this subbuffer * in this state is required to drop records. */ - v_add(config, - subbuffer_get_records_count(config, - &buf->backend, idx), - &buf->records_count); - v_add(config, - subbuffer_count_records_overrun(config, - &buf->backend, - idx), - &buf->records_overrun); + deliver_count_events(config, buf, idx); config->cb.buffer_end(buf, tsc, idx, lib_ring_buffer_get_data_size(config, buf,