Optimise memory consumption, CPU usage and disk writes#381
Merged
nikita-tkachenko-datadog merged 20 commits intoJan 31, 2024
Merged
Conversation
nikita-tkachenko-datadog
marked this pull request as ready for review
January 24, 2024 11:47
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
drodriguezhdez
left a comment
Collaborator
There was a problem hiding this comment.
Dropped some minor comments. Huge refactor, nice work!
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
This file contains hidden or 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
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
Actionto 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-incompatiblelabel attached.do-not-merge/label attached.kind/andseverity/labels attached at least.