Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: the tip of my filterx performance efforts #434

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
24d825c
lib/perf: add support for perf based profiling
bazsi Dec 26, 2024
1431a7a
filterx: use "type" as a description to FilterXExpr type
bazsi Dec 22, 2024
5e727d5
filterx: initialize filterx eval metrics in FilterXExpr
bazsi Dec 23, 2024
a1931a1
filterx: store "name" attribute extra granularity in metrics
bazsi Dec 23, 2024
a3a47ff
filterx: use "type" as a description to FilterXExpr type
bazsi Dec 22, 2024
ce9aa7e
filterx: fix white space issues in the grammar
bazsi Dec 28, 2024
772562a
filterx: add type information into optimization message
bazsi Dec 23, 2024
719cce3
filterx/filterx-ref: move filterx_ref_new() fastpath to an inline fun…
bazsi Jan 3, 2025
4c9e715
filterx: simplify constructors for nullv assignments
bazsi Dec 23, 2024
1789f6e
filterx: rename _eval() methods to specific names
bazsi Dec 28, 2024
a043f04
filterx/filterx-scope: add filterx_variable_handle_is_message_tied() …
bazsi Jan 1, 2025
14c61b2
filterx/filterx-eval: remove partial support for multiple LogMessage …
bazsi Jan 3, 2025
32cd7af
filterx/expr-variable: make template macro based variables read only
bazsi Jan 5, 2025
0172042
filterx/filterx-variable: move FilterXVariableHandle related function…
bazsi Jan 5, 2025
24aed20
filterx/filterx-variable: rename filterx_variable_free to _clear()
bazsi Jan 5, 2025
ae41725
filterx/filterx-variable: introduce "variable_type" at the variable l…
bazsi Jan 5, 2025
8947d6d
logmsg: add generation counter
bazsi Jan 1, 2025
0d0566d
filterx/filterx-scope: keep track of the maximum number of variables
bazsi Jan 4, 2025
fd3ecd3
filterx: do not consider unmarshaling a change in value
bazsi Jan 1, 2025
64830ca
Merge branch 'filterx-refactor-eval-metrics' into tip/axodepot
bazsi Jan 7, 2025
2dbdfc0
Merge branch 'add-syslog-ng-visibility-into-perf-stackdumps' into tip…
bazsi Jan 7, 2025
5d5b17b
Merge branch 'filterx-small-changes' into tip/axodepot
bazsi Jan 7, 2025
2e83990
Merge branch 'filterx-unmarshal-does-not-cause-variables-to-be-dirty'…
bazsi Jan 7, 2025
7ad7171
Merge branch 'logmsg-generation-counter' into tip/axodepot
bazsi Jan 7, 2025
f260e68
Merge branch 'filterx-scope-keep-track-of-maximum-number-of-variables…
bazsi Jan 7, 2025
91da5af
filterx/filterx-scope: remove "log_msg_has_changes"
bazsi Jan 1, 2025
7fb9852
logmsg: make log_msg_make_writable() and related functions inline
bazsi Jan 3, 2025
00aa5ff
filterx/filterx-scope: publish FilterXScope to make it possible to us…
bazsi Jan 3, 2025
4c6bc87
filterx/filterx-scope: associate FilterXScope to the message being pr…
bazsi Jan 5, 2025
638513e
filterx/filterx-scope: make filterx_scope_{is,set}_dirty() inline
bazsi Jan 5, 2025
d9c948b
filterx/filterx-scope: implement LogMessage change tracking in Filter…
bazsi Jan 5, 2025
0043891
filterx/filterx-scope: make dirty tracking more accurate
bazsi Jan 5, 2025
4aeed7f
filterx/filterx-scope: add parent_scope tracking
bazsi Jan 3, 2025
1253178
filterx/filterx-scope: retain the generation counter across clone ope…
bazsi Jan 1, 2025
a0612e5
filterx/filterx-scope: implement delayed variable cloning
bazsi Jan 3, 2025
0c6742f
filterx/filterx-scope: allocate variables inline
bazsi Jan 5, 2025
3c7771f
filterx/filterx-scope: make it possible to allocate FilterXScope on t…
bazsi Jan 3, 2025
332215c
filterx-eval: extract context begin/end code as macros
bazsi Jan 5, 2025
11757be
merge: FIXME
bazsi Jan 3, 2025
7fe138f
WIP: temporarily enable the extraction of source text
bazsi Dec 28, 2024
d54d015
Revert "WIP: temporarily enable the extraction of source text"
bazsi Jan 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ dnl Checks for programs.
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
AM_PROG_AS
if test "x$ac_cv_prog_cc_c99" = "xno"; then
AC_MSG_ERROR([C99 standard compliant C compiler required. Try GCC 3.x or later.])
fi
Expand Down
4 changes: 3 additions & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ include lib/logthrsource/Makefile.am
include lib/logthrdest/Makefile.am
include lib/signal-slot-connector/Makefile.am
include lib/multi-line/Makefile.am
include lib/perf/Makefile.am

LSNG_RELEASE = $(shell echo @PACKAGE_VERSION@ | cut -d. -f1,2)

Expand Down Expand Up @@ -307,7 +308,8 @@ lib_libsyslog_ng_la_SOURCES = \
$(multiline_sources) \
$(logthrsource_sources) \
$(logthrdest_sources) \
$(signal_slot_connector_sources)
$(signal_slot_connector_sources) \
$(perf_sources)

lib_libsyslog_ng_la_CFLAGS = \
$(AM_CFLAGS) \
Expand Down
3 changes: 3 additions & 0 deletions lib/apphook.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "timeutils/cache.h"
#include "multi-line/multi-line-factory.h"
#include "filterx/filterx-globals.h"
#include "perf/perf.h"

#include <iv.h>
#include <iv_work.h>
Expand Down Expand Up @@ -215,6 +216,7 @@ construct_nondumpable_logger(msg_fatal);
void
app_startup(void)
{
perf_global_init();
msg_init(FALSE);
iv_set_fatal_msg_handler(app_fatal);
iv_init();
Expand Down Expand Up @@ -293,6 +295,7 @@ app_shutdown(void)
hostname_global_deinit();
crypto_deinit();
msg_deinit();
perf_global_deinit();


/* NOTE: the iv_deinit() call should come here, but there's some exit
Expand Down
19 changes: 9 additions & 10 deletions lib/filterx/expr-assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ _assign_eval(FilterXExpr *s)
return _assign(self, value);
}

FilterXExpr *
filterx_nullv_assign_new(FilterXExpr *lhs, FilterXExpr *rhs)
{
FilterXBinaryOp *self = g_new0(FilterXBinaryOp, 1);

filterx_binary_op_init_instance(self, "nullv_assign", lhs, rhs);
self->super.eval = _nullv_assign_eval;
self->super.ignore_falsy_result = TRUE;
return &self->super;
}

/* NOTE: takes the object reference */
FilterXExpr *
Expand All @@ -113,3 +103,12 @@ filterx_assign_new(FilterXExpr *lhs, FilterXExpr *rhs)
self->super.ignore_falsy_result = TRUE;
return &self->super;
}

FilterXExpr *
filterx_nullv_assign_new(FilterXExpr *lhs, FilterXExpr *rhs)
{
FilterXExpr *self = filterx_assign_new(lhs, rhs);
self->type = "nullv_assign";
self->eval = _nullv_assign_eval;
return self;
}
6 changes: 3 additions & 3 deletions lib/filterx/expr-comparison.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ _eval_based_on_compare_mode(FilterXExpr *expr, gint compare_mode)
}

static FilterXObject *
_eval(FilterXExpr *s)
_eval_comparison(FilterXExpr *s)
{
FilterXComparison *self = (FilterXComparison *) s;

Expand Down Expand Up @@ -250,7 +250,7 @@ _optimize(FilterXExpr *s)
self->literal_rhs = _eval_based_on_compare_mode(self->super.rhs, compare_mode);

if (self->literal_lhs && self->literal_rhs)
return filterx_literal_new(_eval(&self->super.super));
return filterx_literal_new(_eval_comparison(&self->super.super));

return NULL;
}
Expand All @@ -273,7 +273,7 @@ filterx_comparison_new(FilterXExpr *lhs, FilterXExpr *rhs, gint operator)

filterx_binary_op_init_instance(&self->super, "comparison", lhs, rhs);
self->super.super.optimize = _optimize;
self->super.super.eval = _eval;
self->super.super.eval = _eval_comparison;
self->super.super.free_fn = _filterx_comparison_free;
self->operator = operator;

Expand Down
18 changes: 3 additions & 15 deletions lib/filterx/expr-compound.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ _eval_exprs(FilterXCompoundExpr *self, FilterXObject **result)
}

static FilterXObject *
_eval(FilterXExpr *s)
_eval_compound(FilterXExpr *s)
{
FilterXCompoundExpr *self = (FilterXCompoundExpr *) s;
FilterXObject *result = NULL;
Expand Down Expand Up @@ -168,12 +168,6 @@ _init(FilterXExpr *s, GlobalConfig *cfg)
}
}

stats_lock();
StatsClusterKey sc_key;
stats_cluster_single_key_set(&sc_key, "fx_compound_evals_total", NULL, 0);
stats_register_counter(STATS_LEVEL3, &sc_key, SC_TYPE_SINGLE_VALUE, &self->super.eval_count);
stats_unlock();

return filterx_expr_init_method(s, cfg);
}

Expand All @@ -182,12 +176,6 @@ _deinit(FilterXExpr *s, GlobalConfig *cfg)
{
FilterXCompoundExpr *self = (FilterXCompoundExpr *) s;

stats_lock();
StatsClusterKey sc_key;
stats_cluster_single_key_set(&sc_key, "fx_compound_evals_total", NULL, 0);
stats_unregister_counter(&sc_key, SC_TYPE_SINGLE_VALUE, &self->super.eval_count);
stats_unlock();

for (gint i = 0; i < self->exprs->len; i++)
{
FilterXExpr *expr = g_ptr_array_index(self->exprs, i);
Expand Down Expand Up @@ -231,8 +219,8 @@ filterx_compound_expr_new(gboolean return_value_of_last_expr)
{
FilterXCompoundExpr *self = g_new0(FilterXCompoundExpr, 1);

filterx_expr_init_instance(&self->super);
self->super.eval = _eval;
filterx_expr_init_instance(&self->super, "compound");
self->super.eval = _eval_compound;
self->super.optimize = _optimize;
self->super.init = _init;
self->super.deinit = _deinit;
Expand Down
20 changes: 4 additions & 16 deletions lib/filterx/expr-condition.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ _init(FilterXExpr *s, GlobalConfig *cfg)
return FALSE;
}

stats_lock();
StatsClusterKey sc_key;
stats_cluster_single_key_set(&sc_key, "fx_condition_evals_total", NULL, 0);
stats_register_counter(STATS_LEVEL3, &sc_key, SC_TYPE_SINGLE_VALUE, &self->super.eval_count);
stats_unlock();

return filterx_expr_init_method(s, cfg);
}

Expand All @@ -74,12 +68,6 @@ _deinit(FilterXExpr *s, GlobalConfig *cfg)
{
FilterXConditional *self = (FilterXConditional *) s;

stats_lock();
StatsClusterKey sc_key;
stats_cluster_single_key_set(&sc_key, "fx_condition_evals_total", NULL, 0);
stats_unregister_counter(&sc_key, SC_TYPE_SINGLE_VALUE, &self->super.eval_count);
stats_unlock();

filterx_expr_deinit(self->condition, cfg);
filterx_expr_deinit(self->true_branch, cfg);
filterx_expr_deinit(self->false_branch, cfg);
Expand All @@ -98,7 +86,7 @@ _free(FilterXExpr *s)
}

static FilterXObject *
_eval(FilterXExpr *s)
_eval_conditional(FilterXExpr *s)
{
FilterXConditional *self = (FilterXConditional *) s;
FilterXObject *condition_value = filterx_expr_eval(self->condition);
Expand Down Expand Up @@ -212,8 +200,8 @@ FilterXExpr *
filterx_conditional_new(FilterXExpr *condition)
{
FilterXConditional *self = g_new0(FilterXConditional, 1);
filterx_expr_init_instance(&self->super);
self->super.eval = _eval;
filterx_expr_init_instance(&self->super, "conditional");
self->super.eval = _eval_conditional;
self->super.optimize = _optimize;
self->super.init = _init;
self->super.deinit = _deinit;
Expand All @@ -227,7 +215,7 @@ FilterXExpr *
filterx_conditional_find_tail(FilterXExpr *s)
{
/* check if this is a FilterXConditional instance */
if (s->eval != _eval)
if (s->eval != _eval_conditional)
return NULL;

FilterXConditional *self = (FilterXConditional *) s;
Expand Down
6 changes: 3 additions & 3 deletions lib/filterx/expr-done.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "filterx/object-primitive.h"

static FilterXObject *
_eval(FilterXExpr *s)
_eval_done(FilterXExpr *s)
{
FilterXEvalContext *context = filterx_eval_get_context();
context->eval_control_modifier = FXC_DONE;
Expand All @@ -40,8 +40,8 @@ FilterXExpr *
filterx_expr_done(void)
{
FilterXExpr *self = g_new0(FilterXExpr, 1);
filterx_expr_init_instance(self);
self->eval = _eval;
filterx_expr_init_instance(self, "done");
self->eval = _eval_done;

return self;
}
6 changes: 3 additions & 3 deletions lib/filterx/expr-drop.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "filterx/object-primitive.h"

static FilterXObject *
_eval(FilterXExpr *s)
_eval_drop(FilterXExpr *s)
{
FilterXEvalContext *context = filterx_eval_get_context();
context->eval_control_modifier = FXC_DROP;
Expand All @@ -39,8 +39,8 @@ FilterXExpr *
filterx_expr_drop_msg(void)
{
FilterXExpr *self = g_new0(FilterXExpr, 1);
filterx_expr_init_instance(self);
self->eval = _eval;
filterx_expr_init_instance(self, "drop");
self->eval = _eval_drop;

return self;
}
17 changes: 2 additions & 15 deletions lib/filterx/expr-function.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,26 +242,12 @@ filterx_function_optimize_method(FilterXFunction *s)
gboolean
filterx_function_init_method(FilterXFunction *s, GlobalConfig *cfg)
{
stats_lock();
StatsClusterKey sc_key;
StatsClusterLabel labels[] = { stats_cluster_label("name", s->function_name) };
stats_cluster_single_key_set(&sc_key, "fx_func_evals_total", labels, G_N_ELEMENTS(labels));
stats_register_counter(STATS_LEVEL3, &sc_key, SC_TYPE_SINGLE_VALUE, &s->super.eval_count);
stats_unlock();

return filterx_expr_init_method(&s->super, cfg);
}

void
filterx_function_deinit_method(FilterXFunction *s, GlobalConfig *cfg)
{
stats_lock();
StatsClusterKey sc_key;
StatsClusterLabel labels[] = { stats_cluster_label("name", s->function_name) };
stats_cluster_single_key_set(&sc_key, "fx_func_evals_total", labels, G_N_ELEMENTS(labels));
stats_unregister_counter(&sc_key, SC_TYPE_SINGLE_VALUE, &s->super.eval_count);
stats_unlock();

filterx_expr_deinit_method(&s->super, cfg);
}

Expand Down Expand Up @@ -303,11 +289,12 @@ _function_free(FilterXExpr *s)
void
filterx_function_init_instance(FilterXFunction *s, const gchar *function_name)
{
filterx_expr_init_instance(&s->super);
filterx_expr_init_instance(&s->super, "call");
s->function_name = g_strdup_printf("%s()", function_name);
s->super.optimize = _function_optimize;
s->super.init = _function_init;
s->super.deinit = _function_deinit;
s->super.name = s->function_name;
s->super.free_fn = _function_free;
}

Expand Down
10 changes: 5 additions & 5 deletions lib/filterx/expr-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ filterx_generator_set_fillable(FilterXExpr *s, FilterXExpr *fillable)
}

static FilterXObject *
_eval(FilterXExpr *s)
_eval_generator(FilterXExpr *s)
{
FilterXExprGenerator *self = (FilterXExprGenerator *) s;

Expand All @@ -52,7 +52,7 @@ _eval(FilterXExpr *s)
gboolean
filterx_expr_is_generator(FilterXExpr *s)
{
return s && s->eval == _eval;
return s && s->eval == _eval_generator;
}

FilterXExpr *
Expand All @@ -67,11 +67,11 @@ filterx_generator_optimize_method(FilterXExpr *s)
void
filterx_generator_init_instance(FilterXExpr *s)
{
filterx_expr_init_instance(s);
filterx_expr_init_instance(s, "generator");
s->optimize = filterx_generator_optimize_method;
s->init = filterx_generator_init_method;
s->deinit = filterx_generator_deinit_method;
s->eval = _eval;
s->eval = _eval_generator;
s->ignore_falsy_result = TRUE;
}

Expand Down Expand Up @@ -188,7 +188,7 @@ filterx_generator_create_container_new(FilterXExpr *g, FilterXExpr *fillable_par
{
FilterXExprGeneratorCreateContainer *self = g_new0(FilterXExprGeneratorCreateContainer, 1);

filterx_expr_init_instance(&self->super);
filterx_expr_init_instance(&self->super, "create_container");
self->generator = (FilterXExprGenerator *) g;
self->fillable_parent = fillable_parent;
self->super.optimize = _create_container_optimize;
Expand Down
18 changes: 3 additions & 15 deletions lib/filterx/expr-get-subscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ typedef struct _FilterXGetSubscript
} FilterXGetSubscript;

static FilterXObject *
_eval(FilterXExpr *s)
_eval_get_subscript(FilterXExpr *s)
{
FilterXGetSubscript *self = (FilterXGetSubscript *) s;
FilterXObject *result = NULL;
Expand Down Expand Up @@ -129,12 +129,6 @@ _init(FilterXExpr *s, GlobalConfig *cfg)
return FALSE;
}

stats_lock();
StatsClusterKey sc_key;
stats_cluster_single_key_set(&sc_key, "fx_get_subscript_evals_total", NULL, 0);
stats_register_counter(STATS_LEVEL3, &sc_key, SC_TYPE_SINGLE_VALUE, &self->super.eval_count);
stats_unlock();

return filterx_expr_init_method(s, cfg);
}

Expand All @@ -143,12 +137,6 @@ _deinit(FilterXExpr *s, GlobalConfig *cfg)
{
FilterXGetSubscript *self = (FilterXGetSubscript *) s;

stats_lock();
StatsClusterKey sc_key;
stats_cluster_single_key_set(&sc_key, "fx_get_subscript_evals_total", NULL, 0);
stats_unregister_counter(&sc_key, SC_TYPE_SINGLE_VALUE, &self->super.eval_count);
stats_unlock();

filterx_expr_deinit(self->operand, cfg);
filterx_expr_deinit(self->key, cfg);
filterx_expr_deinit_method(s, cfg);
Expand All @@ -169,8 +157,8 @@ filterx_get_subscript_new(FilterXExpr *operand, FilterXExpr *key)
{
FilterXGetSubscript *self = g_new0(FilterXGetSubscript, 1);

filterx_expr_init_instance(&self->super);
self->super.eval = _eval;
filterx_expr_init_instance(&self->super, "get_subscript");
self->super.eval = _eval_get_subscript;
self->super.is_set = _isset;
self->super.unset = _unset;
self->super.optimize = _optimize;
Expand Down
Loading
Loading