-
Notifications
You must be signed in to change notification settings - Fork 51
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
Optimise memory consumption, CPU usage and disk writes #381
Merged
nikita-tkachenko-datadog
merged 20 commits into
master
from
nikita-tkachenko/memory-consumption-optimization
Jan 31, 2024
Merged
Optimise memory consumption, CPU usage and disk writes #381
nikita-tkachenko-datadog
merged 20 commits into
master
from
nikita-tkachenko/memory-consumption-optimization
Jan 31, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nikita-tkachenko-datadog
changed the title
Nikita tkachenko/memory consumption optimization
Optimise memory consumption and disk writes.
Jan 24, 2024
nikita-tkachenko-datadog
changed the title
Optimise memory consumption and disk writes.
Optimise memory consumption and disk writes
Jan 24, 2024
nikita-tkachenko-datadog
changed the title
Optimise memory consumption and disk writes
Optimise memory consumption, CPU usage and disk writes
Jan 24, 2024
nikita-tkachenko-datadog
added
the
changelog/Fixed
Fixed features results into a bug fix version bump
label
Jan 24, 2024
nikita-tkachenko-datadog
force-pushed
the
nikita-tkachenko/memory-consumption-optimization
branch
from
January 25, 2024 11:57
d691588
to
11d62f5
Compare
nikita-tkachenko-datadog
force-pushed
the
nikita-tkachenko/memory-consumption-optimization
branch
from
January 25, 2024 12:28
11d62f5
to
7eefea6
Compare
…achenko/memory-consumption-optimization
nikita-tkachenko-datadog
force-pushed
the
nikita-tkachenko/memory-consumption-optimization
branch
from
January 26, 2024 10:37
9199d18
to
52371d7
Compare
…achenko/memory-consumption-optimization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped some minor comments. Huge refactor, nice work!
src/main/java/org/datadog/jenkins/plugins/datadog/DatadogUtilities.java
Outdated
Show resolved
Hide resolved
src/main/java/org/datadog/jenkins/plugins/datadog/DatadogUtilities.java
Outdated
Show resolved
Hide resolved
src/main/java/org/datadog/jenkins/plugins/datadog/listeners/DatadogGraphListener.java
Show resolved
Hide resolved
src/main/java/org/datadog/jenkins/plugins/datadog/listeners/DatadogStepListener.java
Show resolved
Hide resolved
src/main/java/org/datadog/jenkins/plugins/datadog/traces/DatadogBasePipelineLogic.java
Outdated
Show resolved
Hide resolved
src/main/java/org/datadog/jenkins/plugins/datadog/traces/DatadogTraceBuildLogic.java
Outdated
Show resolved
Hide resolved
src/main/java/org/datadog/jenkins/plugins/datadog/traces/DatadogTraceBuildLogic.java
Show resolved
Hide resolved
src/main/java/org/datadog/jenkins/plugins/datadog/traces/write/TraceWriter.java
Outdated
Show resolved
Hide resolved
src/main/java/org/datadog/jenkins/plugins/datadog/util/git/RepositoryInfoCallback.java
Show resolved
Hide resolved
drodriguezhdez
previously approved these changes
Jan 30, 2024
Base automatically changed from
nikita-tkachenko/ci-visibility-batching
to
master
January 30, 2024 14:21
nikita-tkachenko-datadog
dismissed
drodriguezhdez’s stale review
January 30, 2024 14:21
The base branch was changed.
drodriguezhdez
previously approved these changes
Jan 30, 2024
drodriguezhdez
previously approved these changes
Jan 30, 2024
drodriguezhdez
approved these changes
Jan 31, 2024
nikita-tkachenko-datadog
deleted the
nikita-tkachenko/memory-consumption-optimization
branch
January 31, 2024 09:38
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements for Contributing to this repository
What does this PR do?
This PR optimises the plugin's resource consumption:
The motivation is that there are several user complaints stating that the overhead of the plugin is too high.
The overhead is mostly caused by how Jenkins' durability mechanism interacts with the plugin. By default Jenkins saves to disk the state of the build at every step (e.g. after finishing a pipeline stage) or with every change (e.g. after adding or removing an
Action
to the build or one of the build's steps). This is needed to ensure durability: if the master node dies, it can be restarted, and the job will resume execution because its up-to-date state will be deserialised from disk.The problem is that the state saved to disk includes all the data that the plugin associates with the build. This data is added to the build as it executes and is retained until the very end of the build execution. It includes steps/stages execution data, build metadata, etc. The reason it is retained until the end of the build is because the trace for the entire build is submitted once the build is finished.
The problem is aggravated by the fact that the data for individual stages and steps is stored in the build object, so with every step and every change all of that data has to be saved. This results in writing and re-writing to disk multiple times the same data, even the data for stages that have already completed.
This is how it contributes to the overhead:
The points above have been corroborated with several JFR profiles obtained from different customers.
To address the issue, the following is changed:
Since now the plugin retains steps/stages data for the shortest possible period, the way data is propagated from steps to stages to builds (this includes, for example, execution node or git metadata) has been reworked as well.
Description of the Change
Alternate Designs
Possible Drawbacks
Verification Process
Since the changes in the behaviour were minimal, existing tests were used to verify there are no regressions.
Some of the tests had to be adjusted because of the way Git metadata is gathered now: the tests have to do actual SCM checkout to better emulate real-life pipelines.
In addition, manual tests were executed in a dockerized Jenkins instance, covering the following:
Freestyle build trace submitted via webhooks
Freestyle build trace submitted via EVP proxy
Freestyle build trace submitted via APM track
Pipeline trace submitted via webhooks
Pipeline trace submitted via EVP proxy
Pipeline trace submitted via APM track
Additional Notes
Release Notes
Review checklist (to be filled by reviewers)
changelog/
label attached. If applicable it should have thebackward-incompatible
label attached.do-not-merge/
label attached.kind/
andseverity/
labels attached at least.