Record event as soon as one filter evaluates to TRUE
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 20 Mar 2020 20:23:17 +0000 (16:23 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 20 Mar 2020 20:54:15 +0000 (16:54 -0400)
This is a tiny optimization but it can reduce tracing cost in cases
where multiple filters are attached to a probe.

Since we want to trace an event if any of its filter expressions
evaluates to TRUE, there is no need to keep on evaluating expressions
once one is found to be TRUE.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6b5b7697869d3e25dc24d38dc39c34ae1d49dcc9

probes/lttng-tracepoint-event-impl.h

index 321cdfa44c61afac7d79c857e4655bf47cc98737..34561243b01502b79db9db6892c2add87f38047c 100644 (file)
@@ -1171,8 +1171,10 @@ static void __event_probe__##_name(void *__data, _proto)               \
                                tp_locvar, _args);                                    \
                lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
                        if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx,       \
-                                       __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
+                                       __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
                                __filter_record = 1;                          \
+                               break;                                        \
+                       }                                                     \
                }                                                             \
                if (likely(!__filter_record))                                 \
                        goto __post;                                          \
@@ -1264,8 +1266,10 @@ static void __event_probe__##_name(void *__data)                       \
                                tp_locvar);                                   \
                lttng_list_for_each_entry_rcu(bc_runtime, &__event->bytecode_runtime_head, node) { \
                        if (unlikely(bc_runtime->filter(bc_runtime, &__lttng_probe_ctx, \
-                                       __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
+                                       __stackvar.__filter_stack_data) & LTTNG_FILTER_RECORD_FLAG)) \
                                __filter_record = 1;                          \
+                               break;                                        \
+                       }                                                     \
                }                                                             \
                if (likely(!__filter_record))                                 \
                        goto __post;                                          \
This page took 0.029186 seconds and 4 git commands to generate.