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

Include target name in the cache key #55

Open
obi1kenobi opened this issue Sep 8, 2023 · 6 comments
Open

Include target name in the cache key #55

obi1kenobi opened this issue Sep 8, 2023 · 6 comments
Labels
C-bug Category: doesn't meet expectations E-help-wanted Call for participation: Help is requested to fix this issue.

Comments

@obi1kenobi
Copy link
Owner

Right now, our cache key includes rustc --version but does not include the target name. This can be a caching problem if someone wants to test multiple targets on the same commit and with the same Rust version, which is entirely reasonable (e.g. #54), if a bit rare.

@obi1kenobi obi1kenobi added C-bug Category: doesn't meet expectations E-help-wanted Call for participation: Help is requested to fix this issue. labels Sep 8, 2023
@Sh0g0-1758
Copy link

Hi, @obi1kenobi. Can you please point out exactly where in the codebase cache key is located?

@obi1kenobi
Copy link
Owner Author

This is it:

const cacheKeyWithLocalHash = `${await this.cacheKey()}-${await this.getLocalCacheHash()}`;

It's constructed from a few different components, but all the building blocks are in the same file so it shouldn't be too hard to see what the key structure currently looks like.

@Sh0g0-1758
Copy link

@obi1kenobi Can you please take a look at my PR and suggest changes in it, if required?

@obi1kenobi
Copy link
Owner Author

@memark if you might have the time and interest, this would be a good issue to tackle to make the target selection a bit more robust.

Otherwise, there's some risk that runs using different targets might end up inappropriately sharing a cache, which could lead to erroneous results.

@memark
Copy link
Contributor

memark commented Jul 14, 2024

Sure, I'd be happy too.

In the declined PR you mentioned that a lot of Rust coding needed to be done in addition to the TypeScript changes. Does that still hold true, and if so what changes would that be?

@obi1kenobi
Copy link
Owner Author

The concern I have (which is possibly unfounded, since I don't know the details of the --target flag) is in a scenario like the following:

  • Say a user is on Linux x86, and runs cargo-semver-checks with default settings.
  • Then say they run cargo-semver-checks on an alternative target, on the same system and after the previous step.

These two runs should not share baseline rustdoc JSON files via the cache. The equivalent scenario using the GitHub Action shouldn't result in cache reuse either. But I'm not convinced that this is correctly handled at the moment — I think cache reuse would happen in both cases.

If so, I think we'll have to:

  • reproduce both bugs with tests, so we know our fixes did indeed fix the problem -- some platform-based cfg!() item inclusions or exclusions should be sufficient;
  • include the rustc target as part of the cache key in cargo-semver-checks itself here
  • include the configured rustc target (if any) to the GitHub Action's own cache key here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: doesn't meet expectations E-help-wanted Call for participation: Help is requested to fix this issue.
Projects
None yet
Development

No branches or pull requests

3 participants