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

Conversation

bazsi
Copy link
Member

@bazsi bazsi commented Dec 30, 2024

Please ignore this PR as it is not intended to be merged. It contains work-in-progress local patches I am yet to extract into separate pull requests.

It is rebased on top of my local merge of all related PRs, so I can maintain those branches separately as they get merged.

@bazsi bazsi force-pushed the filterx-perf-project branch 4 times, most recently from 6e3ce03 to 0b045c1 Compare January 5, 2025 16:32
@bazsi bazsi force-pushed the filterx-perf-project branch from 0b045c1 to b22eedc Compare January 6, 2025 15:53
@bazsi bazsi force-pushed the filterx-perf-project branch 2 times, most recently from fbff61c to 5cab36c Compare January 6, 2025 19:10
bazsi added 3 commits January 7, 2025 18:52
Instead of coding this individually in all FilterXExpr derivatives.

Signed-off-by: Balazs Scheidler <[email protected]>
@bazsi bazsi mentioned this pull request Jan 7, 2025
bazsi added 7 commits January 7, 2025 20:04
…in addition to is_floating

Signed-off-by: Balazs Scheidler <[email protected]>
…instances

We do not really support message contexts (as does the original filter
language and templates), so remove that support.

This makes it simpler to initialize FilterXEvalContext as well as we do
not have to manage the LogMessage array separately.

Signed-off-by: Balazs Scheidler <[email protected]>
It does not really free @self, so it only clears up allocations
within an existing instance, these are usually called *_clear() functions.

Signed-off-by: Balazs Scheidler <[email protected]>
…ayer

Previously the type enum was only used during the initialization of
FilterXExprVariable which was then translated to a set of booleans
at the variable layer. Also clean up naming a bit.

Signed-off-by: Balazs Scheidler <[email protected]>
Signed-off-by: Balazs Scheidler <[email protected]>
@bazsi bazsi force-pushed the filterx-perf-project branch from 486d5b6 to 44a270b Compare January 7, 2025 19:20
bazsi added 2 commits January 7, 2025 20:34
If we pull in a variable from the message and we need to unmarshal it
(e.g. turn FilterXMessageValue to a more specific type like FilterXString or
FilterXJSON), do not consider that a change of that variable.

Changing it in-place, or assignment of a new value should be remain to
be a change.

Signed-off-by: Balazs Scheidler <[email protected]>
bazsi added 16 commits January 7, 2025 20:43
# Conflicts:
#	lib/filterx/expr-compound.c
#	lib/filterx/expr-condition.c
#	lib/filterx/expr-done.c
#	lib/filterx/expr-drop.c
#	lib/filterx/expr-function.c
#	lib/filterx/expr-get-subscript.c
#	lib/filterx/expr-getattr.c
#	lib/filterx/expr-literal.c
#	lib/filterx/expr-set-subscript.c
#	lib/filterx/expr-setattr.c
#	lib/filterx/expr-template.c
#	lib/filterx/expr-variable.c
#	lib/filterx/filterx-expr.c
#	lib/filterx/filterx-expr.h
… into tip/axodepot

# Conflicts:
#	lib/filterx/expr-variable.c
…' into tip/axodepot

# Conflicts:
#	lib/filterx/filterx-scope.c
Previously a coupling was established between logmsg and FilterXScope,
namely whenever the LogMessage was cloned, the logmsg layer called
filterx_scope_set_log_msg_has_changes(), which was then subsequently
used for invalidating message tied variables in the scope.

This was broken for cases where the message was writable, so it changed
without being cloned. In those cases the stale variables survived anyway.

Another issue was that this produced excessive calls to the expensive
filterx_scope_invalidate_log_msg_cache(), as it may be filterx_scope_sync()
that causes the LogMessage to be cloned. In those cases we executed both
filterx_scope_sync() and an entirely unnecessary
filterx_scope_invalidate_log_msg_cache() both iterating on all
FilterXVariable instances in the scope.

This mechanism is being replaced by the generation counter mechanism, but
to make the patches easier to review, this patch just removes the entire
log_msg_has_changes() mechanism.

Signed-off-by: Balazs Scheidler <[email protected]>
…ocessed

I want to delegate the responsibility of tracking LogMessage changes
to the scope (just as floating values are tracked by it), and as
a preparation add a "msg" member to FilterXScope and make sure
it always contains the right message.

Signed-off-by: Balazs Scheidler <[email protected]>
…XScope

Previously message-tied variables were managed in part within expr-variable
and in part within FilterXScope. Now with the message being available
in FilterXScope, we can delegate this in entirety to FilterXScope.

This also implements the validation of message-tied values, so if the
LogMessage changes independently from FilterXScope, we will notice that too
and consider the values of those variables stale.

Signed-off-by: Balazs Scheidler <[email protected]>
A scope is only considered dirty if it has message-tied variables that
are changed. In any other case it's not dirty, so no sync is needed.

Signed-off-by: Balazs Scheidler <[email protected]>
Link scopes together.

Signed-off-by: Balazs Scheidler <[email protected]>
…rations

Previously generations was reset to 0 in case we ended up doing a clone.
Let's retain that instead, so we don't need to adjust the generation
value for FilterXValues either. This is a preparation for sharing
FilterXVariable descriptors so that we don't have to clone them.

Signed-off-by: Balazs Scheidler <[email protected]>
Instead of cloning all variables into subsequent scopes, let's start with an
empty array and only clone the ones that are actually used.  This improves
performance a lot in our use-cases.

Signed-off-by: Balazs Scheidler <[email protected]>
@bazsi bazsi force-pushed the filterx-perf-project branch from 44a270b to 8e3b9c3 Compare January 7, 2025 19:44
bazsi added 6 commits January 7, 2025 20:49
…he stack

At the same time get rid of reference counting and clone.

Signed-off-by: Balazs Scheidler <[email protected]>
Although this code has a single user, it is relatively complex, relies
on arcane mechanics of FilterXScope and FilterXEvalContext. Hide it
and delegate it to show where it belongs.

These have become macros, as we need to use the caller's stack frame to
allocate the scope.


Signed-off-by: Balazs Scheidler <[email protected]>
This reverts commit e93c530c12f03547552449c1fb52437efb9b86cb.
@bazsi bazsi force-pushed the filterx-perf-project branch from 8e3b9c3 to d54d015 Compare January 7, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant