Performance: disable event counting by default
[lttng-ust.git] / libringbuffer / backend_internal.h
index 344784feccde9e5cb042175216840c46ba1aa57d..7bd5c738936084a0ed84fec4fa822a44211812f7 100644 (file)
@@ -196,6 +196,11 @@ int subbuffer_id_check_index(const struct lttng_ust_lib_ring_buffer_config *conf
                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 lttng_ust_lib_ring_buffer_config *config,
                            struct lttng_ust_lib_ring_buffer_backend *bufb,
@@ -206,6 +211,14 @@ void subbuffer_count_record(const struct lttng_ust_lib_ring_buffer_config *confi
        sb_bindex = subbuffer_id_get_index(config, shmp_index(handle, bufb->buf_wsb, idx)->id);
        v_inc(config, &shmp(handle, shmp_index(handle, bufb->array, sb_bindex)->shmp)->records_commit);
 }
+#else /* LTTNG_RING_BUFFER_COUNT_EVENTS */
+static inline
+void subbuffer_count_record(const struct lttng_ust_lib_ring_buffer_config *config,
+                           struct lttng_ust_lib_ring_buffer_backend *bufb,
+                           unsigned long idx, struct lttng_ust_shm_handle *handle)
+{
+}
+#endif /* #else LTTNG_RING_BUFFER_COUNT_EVENTS */
 
 /*
  * Reader has exclusive subbuffer access for record consumption. No need to
@@ -310,6 +323,14 @@ unsigned long subbuffer_get_data_size(
        return shmp(handle, pages->shmp)->data_size;
 }
 
+static inline
+void subbuffer_inc_packet_count(const struct lttng_ust_lib_ring_buffer_config *config,
+               struct lttng_ust_lib_ring_buffer_backend *bufb,
+               unsigned long idx, struct lttng_ust_shm_handle *handle)
+{
+       shmp_index(handle, bufb->buf_cnt, idx)->seq_cnt++;
+}
+
 /**
  * lib_ring_buffer_clear_noref - Clear the noref subbuffer flag, called by
  *                               writer.
@@ -485,7 +506,7 @@ static inline int lttng_ust_fls(unsigned int x)
                r -= 2;
        }
        if (!(x & 0x80000000U)) {
-               x <<= 1;
+               /* No need to bit shift on last operation */
                r -= 1;
        }
        return r;
This page took 0.023299 seconds and 4 git commands to generate.