Skip to content

Conversation

@mikehardy
Copy link
Contributor

Description

👋 this is started with the work on #17871 from @SelaseKay

I worked with Jude on that change in 17871 and while I was in there I noticed that the caching setup for CI in this repo was likely to be subject to severe LRU thrashing and very very low hit rates, with low useful caches even with hits.

In fact when I went to verify that, it was true: https://github.com/firebase/flutterfire/actions/caches?query=sort%3Acreated-asc

The oldest cache is only 35 minutes old - and all the caches are from a branch which means main builds or builds from other branches can't even see them to use them. Thus the caching is for most intents and purposes a lot of computational work for zero benefit at the moment.

How to review this PR - Each commit in this series is a fully separate idea to improve things, and each should be reviewed separately by reading the commit message which explains that specific change then checking the diff for that commit

The basic idea is this though:

  • caches are not visible from branch to main, or between OSs by rule (so you want to cache main but read-only on branch)
  • caches are immutable if the primary key was hit, so key uniqueness is vital, but it must actually change when the cache is known to be stale
  • cache failures shouldn't fail a workflow (it happens, it's a useless flake to fail on)
  • firestore emulators are truly cross-platform so may be shared

In addition, I pinned the Android Emulator runner to a concrete SHA as is practice in this repo

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

it was previously on the sliding v2 tag and could update to unknown
code without notice
use the separate actions/cache "restore" and "save" actions so we may
only save optional based on whether we are on main or not

actions/cache isolates branch caches from main to avoid branch cache
poison attacks on main runs

but branches may see main cache as those caches are considered trustworthy

branch caches do consume available LRU storage though, meaning branch caches
could evict main caches and in high traffic / large cache repositories like
this one that means caches LRU out frequently and cache hit rates are terrible
unless you cache on main only
very occasionally, there are errors in the `hashFiles` function used
to calculate cache keys, and this causes a build error that is a flake,
not a valid CI failure signal

so, continue the workflow even if the caching setup has errors, as
that is a recoverable problem and the workflow may still have a valid
success outcome
github workflow caches are considered immutable, they will never update
if there was a hit on the primary cache key

ergo, if the primary cache key never changes the caches will never update
and you will only ever get fresh caches by chance if stale caches are
evicted via LRU cache storage limit management

So, all cache primary keys are unique now according to the requirements of the specific
cache

- the AVD cache is now unique on the api-level/target/arch tuple, and that
is set and referenced in an environment variable since it is now used in two places

- the firebase emulator cache is set based on the firebase-tools version, which always
changes when new emulator versions are downloaded
@gemini-code-assist
Copy link

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

the downloaded/cached files are pure javascript and java, they may be
shared across operating systems safely
@mikehardy
Copy link
Contributor Author

All of the changes implemented here have either been working well already in the react-native-firebase repo for the parts I had implemented there long ago, or they were implemented in parallel with this one in invertase/react-native-firebase#8820 which is now merged and working well.

I understand CI things are difficult to test, but as far as it goes - that's testing of the same changes and it looks good. Caches over there are now long-lasting where they should be, and updating where they shouldn't, but not thrashing. CI runs are quick

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.

1 participant