Skip to content

Pipeline compilation significantly increased in 7.7.0 in comparison to 7.6.2 #12031

Description

@andsel
  • Version: 7.7.0, 7.7.1, 7.8.0
  • Operating System: any

Starting from Logstash 7.7 was released a feature to put the in logs also the plugin.id to help debugging of problems with pipelines (PR #11078 and #11593) that changed required to "decorate" each plugin invocation with code to set/unset the ThreadLocal with plugin.id (7a22220#diff-aa66540c4668f70bc7568433f4dac1efR155 and 7a22220#diff-aa66540c4668f70bc7568433f4dac1efR172). This introduction of more SythaxElements is causing slow downs in pipeline compilations, introducing a potential regression.

To test it is sufficient to create a pipeline with 500 mutate filters (same filter replicated 500 times) and the pipeline bring more time to be compile in version 7.7 then in version 7.6.2

In some test pipelines we have spot this increment of pipeline compilation times:

7.6.2 7.7.1
1 pipeline ~3 mins ~5 mins
2 pipelines ~3 mins ~17 mins
3 pipelines ~3 mins ~37 mins
4 pipelines ~3 mins ~1h 13 mins

Activity

  1. andsel commented on Jun 17, 2020

    @andsel
    MemberAuthor

    Probably related to #12020

  2. changed the title [-]Regression in pipeline compilation [/-] [+]Pipeline compilation significantly increased in `7.7.0` in comparison to `7.6.2`[/+] on Jun 17, 2020
  3. changed the title [-]Pipeline compilation significantly increased in `7.7.0` in comparison to `7.6.2`[/-] [+]Pipeline compilation significantly increased in 7.7.0 in comparison to 7.6.2[/+] on Jun 17, 2020
  4. jsvd commented on Jun 17, 2020

    @jsvd
    Member

    Here's a minimal code change that, when applied to v7.6.2, triggers this issue when starting two large pipelines.
    Testing with two 3k line pipelines, goes from 3 min startup to > 10 minutes.

    diff --git a/logstash-core/src/main/java/org/logstash/config/ir/compiler/DatasetCompiler.java b/logstash-core/src/main/java/org/logstash/config/ir/compiler/DatasetCompiler.java
    index 785c09160..50cf6fc1e 100644
    --- a/logstash-core/src/main/java/org/logstash/config/ir/compiler/DatasetCompiler.java
    +++ b/logstash-core/src/main/java/org/logstash/config/ir/compiler/DatasetCompiler.java
    @@ -196,7 +196,7 @@ public final class DatasetCompiler {
             final ValueSyntaxElement inputBuffer, final ClassFields fields,
             final AbstractFilterDelegatorExt plugin) {
             final ValueSyntaxElement filterField = fields.add(plugin);
    -        final Closure body = Closure.wrap(
    +        final Closure body = Closure.wrap(setPluginIdForLog4j(plugin),
                 buffer(outputBuffer, filterField.call("multiFilter", inputBuffer))
             );
             if (plugin.hasFlush()) {
    @@ -303,6 +303,11 @@ public final class DatasetCompiler {
             );
         }
     
    +    private static MethodLevelSyntaxElement setPluginIdForLog4j(final AbstractFilterDelegatorExt filterPlugin) {
    +        final IRubyObject pluginId = filterPlugin.getId();
    +        return () -> "org.apache.logging.log4j.ThreadContext.put(\"plugin.id\", \"" + pluginId + "\")";
    +    }
    +
         private static MethodLevelSyntaxElement clear(final ValueSyntaxElement field) {
             return field.call("clear");
         }

    Creating a method for each plugin id seems to blow up compilation.

  5. colinsurprenant commented on Jun 18, 2020

    @colinsurprenant
    Contributor

    Fix in #12038

  6. added a commit that references this issue on Jun 25, 2020
    1a11abd
  7. added 3 commits that reference this issue on Jun 25, 2020
    ffac2df
    d767848
    84f9154
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions