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

GitHub Actions pr_ci.yml improvements #12589

Closed
wants to merge 37 commits into from

Conversation

lahma
Copy link
Contributor

@lahma lahma commented Oct 8, 2022

Relates to #12583 , checking how to make PR CI build faster on GH actions side.

  • NuGet packages probably come faster from local data center than public download interface
  • Don't install .NET 6 (comes OOB), don't install Node.JS 15 (v16 comes OOB)
  • Add hard-linking to improve build speeds on Windows, some discussion about the feature (not working inside VS but for CI build seems like a good choice)

Probably not a common thing to see Windows build completing faster than the Linux one?

image

I'd so much love to have NUKE used in this project, but I guess that's way too far-fetched...

@lahma lahma force-pushed the add-cache-to-actions branch 2 times, most recently from f3dade7 to 28404a1 Compare October 8, 2022 08:33
@lahma lahma changed the title Add cache action for NuGet packages to pr_ci.yml GitHub Actions pr_ci.yml improvements Oct 8, 2022
@lahma lahma marked this pull request as ready for review October 8, 2022 09:24
@Skrypt
Copy link
Contributor

Skrypt commented Oct 8, 2022

It is the first time I hear about https://nuke.build/
Looks nice. Maybe a small POC to see the build times and compare first.

.github/workflows/pr_ci.yml Outdated Show resolved Hide resolved
@lahma
Copy link
Contributor Author

lahma commented Oct 9, 2022

It is the first time I hear about nuke.build Looks nice. Maybe a small POC to see the build times and compare first.

I'll create a PR to show the thing. Just yesterday I just wanted to delete all binaries in OC build folders (netcoreapp3.1 and net5.0) leftovers, dotnet clean etc didn't help much so had to do manual search and delete. When using NUKE I would have just said .\build.cmd clean on command line to get it cleaned. Having common tasks and automation in c# really helps, but a PR will follow!

@Skrypt
Copy link
Contributor

Skrypt commented Oct 9, 2022

I generally do git clean -xdf for that matter but sometimes it's a little too much. 😄

@hishamco
Copy link
Member

hishamco commented Oct 9, 2022

I suffered a lot in the paste, but I did what Jasmin suggested with clean everyting which is too much ;)

@hishamco
Copy link
Member

hishamco commented Oct 9, 2022

I think we need to discuss to support NUKE or not, or we can use programmable MSBuild tasks like what I started long time ago

@hishamco
Copy link
Member

hishamco commented Oct 9, 2022

For reference #9247 and #12364

@lahma
Copy link
Contributor Author

lahma commented Oct 9, 2022

NUKE has the advantage that you can debug it too when needed using the IDE.

@hishamco
Copy link
Member

hishamco commented Oct 9, 2022

Sounds good, can we open a discussion for this one, so others can add thier comments and ideas

Comment on lines 20 to 54
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
Copy link
Member

@Piedone Piedone Oct 11, 2022

Choose a reason for hiding this comment

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

Could you do some repeated measurements before/after (just with the caching change) so we can see an average for the total workflow runtime (or cache+build)? Two GHA builds can vary wildly between two runs, so any two builds are not really comparable.

We've experimented around for NuGet and NPM caching with our OSOCE solution, which uses OrchardCore.Application.Cms.Targets (so basically every Orchard package) and some, so it should be comparable in terms of NuGet restore requirements. It turned out that restoring the cache under Windows is so slow that it cancels out the savings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll check with some verbose output...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comment I made at the end shows the results, with no restore it's faster to have the cache in use. Restore is I/O intensive even when nothing needs to be restored (NuGet cache contains items).

Copy link
Member

Choose a reason for hiding this comment

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

If you mean this comment then I only see a single measurement. Sorry for being a pain here, it's just that a +-10% jitter in the performance of GitHub Actions builds is usual, with particularly (un)lucky ones even hitting outside of that, so while this is promising, I'd like to see with multiple runs whether the speedup persists.

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

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

Interesting things, thank you! I'll check out the hard link build in our workflows too, I'm curious about the impact.

Comment on lines 18 to 23
- uses: actions/setup-node@v2
- uses: actions/cache@v3
with:
node-version: "15"
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about these. While it's great to save on having to do these, but we also take a dependency on ubuntu-latest and windows-latest containing the version we want, and if the images are updated, our build can break without us touching it. Perhaps these actions could instead be optimized not to do the installation if it's already available?

Copy link
Member

Choose a reason for hiding this comment

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

Could you reply, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely no need to install Node 15 when 16 is LTS, seems that for Windows image every unnecessary step will be slow. Using -latest already makes building unpredictable - it can be Windows 2032 some day.

Copy link
Member

Choose a reason for hiding this comment

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

We definitely shouldn't use v15 of Node, I agree. However, that doesn't necessarily mean we should use the version provided by the image, which is not really something contributors would keep in mind. While using the "latest" images indeed poses a similar issue, I'd say that the chance that a Node or .NET SDK version update brings issues is at least an order of magnitude larger, than that of other image updates, especially OS ones. It's anecdotal, but we even had minor .NET SDK versions breaking the build here (and I've seen that many times with our other apps at Lombiq too), while I can't remember OS updates breaking anything like this.

Similar to setup-dotnet, setup-node
won't install anything if the version already exists locally. So if we target v16 (since the 3 latest LTS versions are pre-installed) then this shouldn't be significantly slower than not doing anything, while retaining that the version we use for the build is known.

Comment on lines 21 to 25
- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
include-prerelease: true
Copy link
Member

Choose a reason for hiding this comment

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

v3 of actions/setup-dotnet already includes a feature not to install a given version if it already exists on the VM. So, using it should be enough for us to use the version we want if it exists on the image but still get the speedup: https://github.com/Lombiq/GitHub-Actions/pull/67/files#diff-7978921ed7153ba992ebf38332bdd64fe6f3acb10a452b2978859c5a835ea74bR30 (note the comment above, I initially understood the behavior differently).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally build system would handle this. For example NUKE checks solution's global.json for required SDK version and downloads if needed. Works also outside of GitHub. But probably upgrading actions is the way to go when we can't use the best tools..

Copy link
Member

Choose a reason for hiding this comment

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

Well, we can have something fancy, but in the short term, just pointing this action to v3 will optimize this :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just had a run using v3 and it took 1m 29s, so it still comes with a price...

image

Copy link
Member

Choose a reason for hiding this comment

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

That's supposed to be a lot faster... In practice I've seen <20s for this (vs ~3 minutes for a full install). So, I don't know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

15 seconds is quite long time for no-op?

Copy link
Member

Choose a reason for hiding this comment

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

That's what I initially thought as well, but as someone kindly explained in the mentioned thread it's not a no-op :). It's also checking the latest released 6.0.x version online, and if it's newer than the pre-installed one, installs that instead.

@sebastienros
Copy link
Member

I'd so much love to have NUKE

Go to hell Marko

@Piedone
Copy link
Member

Piedone commented Oct 13, 2022

Don't merge, see my comments.

@lahma lahma force-pushed the add-cache-to-actions branch from 8cc1361 to 4ab6ce4 Compare October 15, 2022 05:51
@lahma
Copy link
Contributor Author

lahma commented Oct 15, 2022

So because changes requested status I can't get builds to run? Not so convenient...

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

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

I dont know why the build is not running, I think it should (I certainly don't see any way to let it run). I'll add an approval to see if it helps but please note that still, I don't think this should yet be merged.

@Piedone
Copy link
Member

Piedone commented Oct 15, 2022

Still nothing. I don't know... Please try to push again and let's see if the build kicks off.

@lahma lahma force-pushed the add-cache-to-actions branch 2 times, most recently from 460a297 to bc5b166 Compare October 16, 2022 06:17
@lahma
Copy link
Contributor Author

lahma commented Oct 16, 2022

Sorry, by bad. The YAML had indent problem, this is why tools like NUKE generate the YAML for you...

@lahma lahma force-pushed the add-cache-to-actions branch from dd5f008 to 227b396 Compare October 20, 2022 05:37
@lahma lahma force-pushed the add-cache-to-actions branch from 144e584 to c77ac62 Compare October 20, 2022 05:43
@lahma lahma force-pushed the add-cache-to-actions branch from 9b8f83c to 7129dfc Compare October 20, 2022 06:23
@lahma lahma force-pushed the add-cache-to-actions branch from 7129dfc to d2619c0 Compare October 20, 2022 06:32
@lahma lahma force-pushed the add-cache-to-actions branch from d2619c0 to 233f62a Compare October 20, 2022 06:43
@Piedone
Copy link
Member

Piedone commented Jan 10, 2024

Is this something you'd like to revisit @lahma or should we close?

@lahma lahma closed this Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants