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

Chore/perf improvements #7612

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Chore/perf improvements #7612

wants to merge 2 commits into from

Conversation

loicmathieu
Copy link
Member

Replacing MapUtils.merge() by putAll() avoid costly operations that clone the Map. As this is called a lot of time for complex workflow, this has a non-negligible impact.

Using this flow (2.1k taskruns):

id: outputs
namespace: company.team

tasks:
  - id: forEach1
    type: io.kestra.plugin.core.flow.ForEach
    values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    tasks:
    - id: forEach2
      type: io.kestra.plugin.core.flow.ForEach
      values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
      tasks:
      - id: forEach3
        type: io.kestra.plugin.core.flow.ForEach
        values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
        tasks:
        - id: output
          type: io.kestra.plugin.core.output.OutputValues
          values:
            attr: "{{parents[1].taskrun.value}}-{{parent.taskrun.value}}-{{taskrun.value}}"
        - id: log
          type: io.kestra.plugin.core.log.Log
          message: "{{currentEachOutput(outputs.output).values.attr}}"

Performance is improved by approx 15% (24mn44s -> 21mn17s), more importantly, allocations are greatly reduced and JVM costs lowered.

Approx improvements:

  • The CPU cost of Execution.output() goes from 11% of samples to less than 2%
  • The allocation cost of Execution.output() goes from 17% of samples to less than 5%
  • Global GC cost goes from 32% of samples to less than 22% (those are CPU costs)

See the following flamegraphs (zoomed on the execution queue) for more information.

Before - CPU profile
image

** After - CPU profile**
image

Before - Allocation profile
image

After - Allocation profile
image

Copy link

codecov bot commented Feb 27, 2025

❌ 54 Tests Failed:

Tests completed Failed Passed Skipped
1649 54 1595 19
View the top 3 failed test(s) by shortest run time
io.kestra.runner.h2.H2RunnerTest workerSuccess()
Stack Traces | 0.111s run time
java.lang.AssertionError: 
Expected: is <SUCCESS>
     but: was <FAILED>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at io.kestra.plugin.core.flow.WorkingDirectoryTest$Suite.success(WorkingDirectoryTest.java:124)
	at io.kestra.core.runners.AbstractRunnerTest.workerSuccess(AbstractRunnerTest.java:278)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.micronaut.test.extensions.junit5.MicronautJunit5Extension$2.proceed(MicronautJunit5Extension.java:142)
	at io.micronaut.test.extensions.AbstractMicronautExtension.interceptEach(AbstractMicronautExtension.java:162)
	at io.micronaut.test.extensions.AbstractMicronautExtension.interceptTest(AbstractMicronautExtension.java:119)
	at io.micronaut.test.extensions.junit5.MicronautJunit5Extension.interceptTestMethod(MicronautJunit5Extension.java:129)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
io.kestra.runner.h2.H2RunnerTest waitFor()
Stack Traces | 0.118s run time
java.lang.AssertionError: 
Expected: is <SUCCESS>
     but: was <FAILED>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at io.kestra.plugin.core.flow.WaitForCaseTest.waitfor(WaitForCaseTest.java:26)
	at io.kestra.core.runners.AbstractRunnerTest.waitFor(AbstractRunnerTest.java:423)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.micronaut.test.extensions.junit5.MicronautJunit5Extension$2.proceed(MicronautJunit5Extension.java:142)
	at io.micronaut.test.extensions.AbstractMicronautExtension.interceptEach(AbstractMicronautExtension.java:162)
	at io.micronaut.test.extensions.AbstractMicronautExtension.interceptTest(AbstractMicronautExtension.java:119)
	at io.micronaut.test.extensions.junit5.MicronautJunit5Extension.interceptTestMethod(MicronautJunit5Extension.java:129)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
io.kestra.runner.h2.H2RunnerTest waitforNoSuccess()
Stack Traces | 0.13s run time
java.lang.AssertionError: 
Expected: is <SUCCESS>
     but: was <FAILED>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at io.kestra.plugin.core.flow.WaitForCaseTest.waitforNoSuccess(WaitForCaseTest.java:45)
	at io.kestra.core.runners.AbstractRunnerTest.waitforNoSuccess(AbstractRunnerTest.java:441)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.micronaut.test.extensions.junit5.MicronautJunit5Extension$2.proceed(MicronautJunit5Extension.java:142)
	at io.micronaut.test.extensions.AbstractMicronautExtension.interceptEach(AbstractMicronautExtension.java:162)
	at io.micronaut.test.extensions.AbstractMicronautExtension.interceptTest(AbstractMicronautExtension.java:119)
	at io.micronaut.test.extensions.junit5.MicronautJunit5Extension.interceptTestMethod(MicronautJunit5Extension.java:129)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@loicmathieu loicmathieu force-pushed the chore/perf-improvements branch from 03c8a45 to 2992172 Compare February 28, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To review
Development

Successfully merging this pull request may close these issues.

1 participant