Skip to content

build: always cache LLVM source/build even if the tests fail to avoid extra rebuilds #3453

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

Merged
merged 5 commits into from
Feb 17, 2023

Conversation

deadprogram
Copy link
Member

This PR modifies the GH actions builds to always cache LLVM source/build even if the tests fail to avoid extra rebuilds.

See https://github.com/actions/cache/tree/main/save#always-save-cache for details

Copy link
Member

@aykevl aykevl left a comment

Choose a reason for hiding this comment

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

Yes yes yes! We had this in CircleCI but at the time it wasn't possible in GitHub Actions.

I don't think the path parameter is necessary for restore. Otherwise it looks good to me.

@deadprogram
Copy link
Member Author

The example I looked at in the docs here did that with the path, so I copied it: https://github.com/actions/cache#using-a-combination-of-restore-and-save-actions

@deadprogram
Copy link
Member Author

Once I have this working correctly for Windows, I will do the same thing for the other targets in a subsequent PR, just so we can get the Windows builds unstuck.

@aykevl
Copy link
Member

aykevl commented Feb 16, 2023

It doesn't include the cache here: https://github.com/actions/cache/tree/main/save#re-evaluate-cache-key-while-saving
Also, it doesn't make sense to include paths in the restore steps. It just restores whatever was saved. I think the example you used is wrong.

@deadprogram
Copy link
Member Author

OK I will remove that in the later PR just to let the current build try to finish.

@deadprogram
Copy link
Member Author

@aykevl turns out you do need that:

Input required and not supplied: path

@deadprogram deadprogram force-pushed the windows-llvm-cache branch 2 times, most recently from f1d1c2c to ba4553f Compare February 16, 2023 21:55
@aykevl
Copy link
Member

aykevl commented Feb 16, 2023

@aykevl turns out you do need that:

Input required and not supplied: path

Yeah you are correct, I later found out the path is required. Which doesn't make a lot of sense to me to be honest (it wasn't required in CircleCI).

@deadprogram
Copy link
Member Author

@aykevl just wonder if we should either remove the LLVM source cache tasks, or remove this?

# fetch LLVM source
rm -rf llvm-project
make llvm-source

Seems like something not quite correct here.

@aykevl
Copy link
Member

aykevl commented Feb 16, 2023

@aykevl just wonder if we should either remove the LLVM source cache tasks, or remove this?

# fetch LLVM source
rm -rf llvm-project
make llvm-source

Seems like something not quite correct here.

I believe this is working as intended. The way it works now is as follows:

  • Cache the bits of llvm-project that are used for all CI runs (which is a small subset of the entire llvm-project tree).
  • Download the entire llvm-project directory (not just the cached subset) for LLVM builds.

This provides quick cache restores in the common case when LLVM isn't built (the llvm-project directory is large so caching only a subset provides a significant speedup. But when LLVM needs to be rebuilt, this cached version isn't good enough. It's possible to also cache the full LLVM source tree but as it's only needed for LLVM builds it won't help CI times much.

@deadprogram deadprogram force-pushed the windows-llvm-cache branch 3 times, most recently from 09a0ee2 to 6f53911 Compare February 17, 2023 12:18
@aykevl
Copy link
Member

aykevl commented Feb 17, 2023

Some notes:

  • I tried building with thread support many times (for example here: ci: try to build LLVM with thread support #2433) but didn't succeed. It works locally, but doesn't work in CI. Very frustrating.
  • I doubt stack size is the real issue here. I'm suspecting some sort of memory corruption that is then presented as a stack overflow. Especially as it only happens sometimes.

@deadprogram
Copy link
Member Author

I'm suspecting some sort of memory corruption that is then presented as a stack overflow. Especially as it only happens sometimes.

Finally passed, but seems like it fails more often then passes.

@deadprogram deadprogram merged commit 012bdfa into dev Feb 17, 2023
@deadprogram deadprogram deleted the windows-llvm-cache branch February 17, 2023 16:52
Comment on lines +46 to +56
- name: Save LLVM source cache
uses: actions/cache/save@v3
if: steps.cache-llvm-source.outputs.cache-hit != 'true'
with:
key: ${{ steps.cache-llvm-source.outputs.cache-primary-key }}
path: |
llvm-project/clang/lib/Headers
llvm-project/clang/include
llvm-project/compiler-rt
llvm-project/lld/include
llvm-project/llvm/include
Copy link
Member

Choose a reason for hiding this comment

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

Why did you add this step?

Copy link
Member Author

Choose a reason for hiding this comment

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

All of the LLVM source is cached and also all of the LLVM builds are cached for each of the build platforms which need it.

Comment on lines +126 to +131
- name: Configure pagefile
uses: al-cheb/[email protected]
with:
minimum-size: 8GB
maximum-size: 24GB
disk-root: "C:"
Copy link
Member

Choose a reason for hiding this comment

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

Was the page file too small? Or why did you add this?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is to give more virtual memory via pagefile to the Windows build instances, since they have unused space on C: drive. See https://github.com/easimon/maximize-build-space#how-it-works for the inspiration.

Did it actually help? I cannot say really.

waj334 pushed a commit to waj334/tinygo that referenced this pull request Feb 24, 2023
… extra rebuilds (tinygo-org#3453)

builds/macos, linux, windows: update to explicit restore/save for LLVM source and LLVM builds
conejoninja pushed a commit to conejoninja/tinygo that referenced this pull request Mar 22, 2023
… extra rebuilds (tinygo-org#3453)

builds/macos, linux, windows: update to explicit restore/save for LLVM source and LLVM builds
deadprogram added a commit that referenced this pull request Mar 28, 2023
… extra rebuilds (#3453)

builds/macos, linux, windows: update to explicit restore/save for LLVM source and LLVM builds
LiuJiazheng pushed a commit to LiuJiazheng/tinygo that referenced this pull request Aug 20, 2023
… extra rebuilds (tinygo-org#3453)

builds/macos, linux, windows: update to explicit restore/save for LLVM source and LLVM builds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants