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

Improve examples cache #1717

Merged
merged 4 commits into from
Feb 29, 2024
Merged

Improve examples cache #1717

merged 4 commits into from
Feb 29, 2024

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Feb 28, 2024

Fleshing out the examples cache a bit. With the introduction of PULUMI_CONVERT=1 the build times are making large providers like AWS very unpleasant to work with. In particular examples are being re-rendered repeatedly across make tfgen and make build_sdks as well as across multiple passes through the provider. This PR improves pre-existing examples cache a bit with the following goals in mind:

  • a lot more information that might be relevant to examples generation is captured into the cache key
  • so that changes in tooling versions that might affect example rendering should invalidate the cache
  • cache directories now have a metadata file explaining the details of the cache key
  • PULUMI_CONVERT=1 style conversions now support accelerating through the cache
  • this is slightly tricky as PULUMI_CONVERT=1 bulk-detects HCLs but now needs to be aware of the cache to skip them
  • cache hits should not affect example coverage tracker metrics

Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

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

Looks good to me.

I'd be comfortable disabling gosec. I'm struggling to think of a case where it flagged an error for us.

if cliConverterEnabled() {
cache := g.getOrCreateExamplesCache()
if r, ok := cache.Lookup(hclCode, languageName); ok {
convertedHcl = r
Copy link
Member

Choose a reason for hiding this comment

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

Are we not returning here because we want g.coverageTracker.languageConversionSuccess(e, languageName, convertedHcl) to trigger later down?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's right. Looks like this results in a redundant cache.Store call. I can fix that up.

Copy link

codecov bot commented Feb 29, 2024

Codecov Report

Attention: Patch coverage is 88.48921% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 59.21%. Comparing base (e336d98) to head (7a061ae).
Report is 2 commits behind head on master.

Files Patch % Lines
pkg/tfgen/convert_cli.go 57.14% 5 Missing and 1 partial ⚠️
pkg/tfgen/examples_cache.go 94.91% 5 Missing and 1 partial ⚠️
pkg/tfgen/docs.go 42.85% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1717      +/-   ##
==========================================
- Coverage   59.62%   59.21%   -0.41%     
==========================================
  Files         299      307       +8     
  Lines       41918    42403     +485     
==========================================
+ Hits        24993    25109     +116     
- Misses      15492    15860     +368     
- Partials     1433     1434       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@t0yv0 t0yv0 enabled auto-merge (squash) February 29, 2024 16:09
@t0yv0 t0yv0 merged commit 6b98cea into master Feb 29, 2024
9 checks passed
@t0yv0 t0yv0 deleted the t0yv0/examples-cache branch February 29, 2024 16:27
@t0yv0 t0yv0 restored the t0yv0/examples-cache branch February 29, 2024 19:15
@t0yv0 t0yv0 deleted the t0yv0/examples-cache branch February 29, 2024 19:15
iwahbe added a commit that referenced this pull request Apr 3, 2024
Originally removed in #1717.
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.

None yet

2 participants