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

CI: Faster GetReleaseVersion and Release/Upload Artifacts jobs #68

Merged
merged 4 commits into from
Jul 29, 2020

Conversation

DeeDeeG
Copy link
Member

@DeeDeeG DeeDeeG commented Jul 26, 2020

Requirements for Contributing a Performance Improvement

Description of the Change

Run GetReleaseVersion (the first step) and the "Release"/"Upload Artifacts" (the last step on the Nightly/Release Branch pipelines) on ubuntu-latest. This alone has the most profound performance impact.

Doing npm install [and git clone] is slower on Windows, due to NTFS's poor performance writing lots of small files versus EXT4.

Interesting discussion here: https://github.com/rust-lang/rustup/issues/1540

Beyond that, further tweak GetReleaseVersion to use npm ci rather than npm install. This saves up to about 25 to 40 seconds or so per run.

In order to run these jobs of CI on Ubuntu, backslashes \ were converted to forward-slashes /. This has the side benefit that these jobs may now be run on any OS, should it be desirable to do so in the future.

Background on slashes ("\" and "/"):

The cd and node commands each perfectly understand forward-slashes / to be directory separators, if used in command-line arguments, regardless of OS (yes, even on Windows). There is no need to use Windows-only backslashes \, which are interpreted as escape characters on Unix-likes such as Ubuntu and macOS. As it turns out, we only ever use backslashes \ in paths passed as command-line arguments to cd or node. So in all of our CI configs, it is never required that we use backslashes \, and we could replace all of them with forward-slashes / if we wanted to. I have left the conditional, Windows-only ones in for now, since they aren't hurting anything.)

Quantitative Performance Benefits

About 30 seconds to 1 minute faster GetReleaseVersion (the very first stage of CI, which must finish for the rest of CI to happen).

Presumably similar impact to the final "make releases"/"upload artifacts" steps of CI.

Edit to add some informal "benchmarks" I ran for just the GetReleseVersion job:
https://dev.azure.com/DeeDeeG/b/_build/results?buildId=209&view=results

From fastest to slowest:

  • Ubuntu Bionic (~22-25 seconds)
  • macOS Catalina (~23-25 seconds)
  • Ubuntu Xenial (~25-35 seconds)
  • Ubuntu Focal (~30-37 seconds)
  • Windows (either version) (~50 seconds to 1 minute 30 seconds)

I ran seven runs of this (again, informal benchmarks) and results were usually within those ranges, with some slower outliers.

Runs might be a bit faster on my personal fork with fetch-depth set to 7 for the implicit git checkout task. The atomcommunity Azure Pipelines project currently has it set to a more-conservative depth of 15.

Possible Drawbacks

None that I can think of. A pretty small and simple change for a minute or so of speedup.

Verification Process

Passed CI on my personal fork. Should pass CI here.

Compare runs before/after this PR to see that the typical GetReleaseVersion job is faster and takes a more consistent amount of time. With this PR, the GetReleaseVersion job lasts about 30 seconds or so every time. Before this PR, GetReleaseVersion lasted from about 1 minute to 1 minute 30 seconds.

I haven't compared the run time of the Release/Upload Artifacts jobs, because we have no passing runs of that. See the fix in #66 so we can start comparing run times for that.

Applicable Issues

#1 (comment)

Release Notes

N/A

Backslashes ("\") can be interpreted as escape characters
on Unix (Linux, macOS). Replace with forward-slashes, "/",
which are interpreted the same (as directory separators) on all OSes,
at least in arguments to commands such as `cd` and `node`.
Ubuntu is much faster than Windows at installing many small files,
such as during `git clone` and `npm install`.
This should be marginally faster. No need to run on Windows.
@DeeDeeG DeeDeeG changed the title Faster get release version and release CI: Faster GetReleaseVersion and Release/Upload Artifacts jobs Jul 26, 2020
Comment on lines 4 to 12
vmImage: 'windows-latest'
vmImage: 'ubuntu-latest'
steps:
# This has to be done separately because VSTS inexplicably
# exits the script block after `npm install` completes.
- script: |
cd script\vsts
npm install
cd script/vsts
npm install request-promise-native yargs
displayName: npm install
- script: node script\vsts\get-release-version.js --nightly
- script: node script/vsts/get-release-version.js --nightly
Copy link
Member

@aminya aminya Jul 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make these a template? We can do it in a separate PR too. No difference.

Copy link
Member Author

@DeeDeeG DeeDeeG Jul 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing!

Separate PR strikes me as the right approach. Easier to look back at the history and see what happened.

Will do it right away though after/if this gets merged.

Edit: Issue for this: #69

@aminya
Copy link
Member

aminya commented Jul 26, 2020

Thanks. It is twice faster 😄 🎉

@DeeDeeG

This comment has been minimized.

@DeeDeeG DeeDeeG force-pushed the faster-GetReleaseVersion-and-Release branch from 7af6423 to ef6f0ca Compare July 26, 2020 17:17
`npm ci` doesn't try to reconcile package.json with package-lock.json,
nor with any existing packages in `node_modules`. `npm ci` simply
deletes `node_modules` and uses the packages from `package-lock.json`.

As a result, `npm ci` is much, much faster than `npm install`.
We should use it wherever possible.
@DeeDeeG DeeDeeG force-pushed the faster-GetReleaseVersion-and-Release branch from ef6f0ca to dd5d536 Compare July 26, 2020 17:36
@DeeDeeG DeeDeeG added the CI label Jul 27, 2020
@DeeDeeG
Copy link
Member Author

DeeDeeG commented Jul 27, 2020

@aminya this is ready to go if you are okay with it.

@DeeDeeG
Copy link
Member Author

DeeDeeG commented Jul 28, 2020

Going to merge this some time tomorrow if I don't hear back. It's a tiny change, and it's working great.

@DeeDeeG
Copy link
Member Author

DeeDeeG commented Aug 4, 2020

Upstream PR: atom#21147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants