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

Filterx scope optimizations #468

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

bazsi
Copy link
Member

@bazsi bazsi commented Jan 23, 2025

This goes on top of #467 and brings significant performance improvements for FilterXScope

@bazsi bazsi force-pushed the filterx-scope-optimizations branch 2 times, most recently from 5d3151c to 0138d38 Compare January 24, 2025 09:36
bazsi added 6 commits January 24, 2025 11:10
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 <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
…rations

Previously scope->generation was reset to 0 in case we ended up doing a
scope clone operation.

Let's retain the generation counter instead, so we don't need to adjust the
generation value for FilterXValues either.  Also, subsequent patches will
start sharing FilterXVariable instances, meaning we want to know which
generation a specific variable is associated with.

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
…e inline functions

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
…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 <balazs.scheidler@axoflow.com>
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
@bazsi bazsi force-pushed the filterx-scope-optimizations branch from 0138d38 to 367b2a5 Compare January 24, 2025 10:20
bazsi added 4 commits January 24, 2025 11:24
…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 <balazs.scheidler@axoflow.com>
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 <balazs.scheidler@axoflow.com>
Link scopes together.

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
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 <balazs.scheidler@axoflow.com>
@bazsi bazsi force-pushed the filterx-scope-optimizations branch from 367b2a5 to 239d160 Compare January 24, 2025 11:42
bazsi added 3 commits January 24, 2025 12:48
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
…he stack

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

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
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 <balazs.scheidler@axoflow.com>
@bazsi bazsi force-pushed the filterx-scope-optimizations branch from 239d160 to 2e78a74 Compare January 24, 2025 11:48
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