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

Store Helm indexes in JSON format #1178

Merged
merged 1 commit into from
Aug 7, 2023
Merged

Conversation

somtochiama
Copy link
Member

Closes #1172

Store helm indexes in JSON format for more efficient caching.
See linked issue above for more details.

@somtochiama somtochiama requested a review from hiddeco July 25, 2023 10:53
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

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

Will need to reserve some time to go through this in depth, but while I do this, you can continue to optimize the loading logic as done here:

https://github.com/helm/helm/blob/2544aa23a33977d91fe8f59d12dd923dc43be6c5/pkg/repo/index.go#L378-L390

@hiddeco hiddeco added enhancement New feature or request area/helm Helm related issues and pull requests labels Jul 28, 2023
@hiddeco hiddeco added this to the Helm GA milestone Jul 28, 2023
@hiddeco hiddeco changed the title Store helm indexes in JSON format Store Helm indexes in JSON format Aug 2, 2023
@hiddeco
Copy link
Member

hiddeco commented Aug 2, 2023

Tested this change against two scenarios:

  1. Having 50 HelmRepositories with one HelmChart each (based on the top 50 from ArtifactHub). Interval on all resources set to 5m.
  2. Having 1 Helmrepository (the Bitnami full index at ~20MiB) with 50 HelmCharts. Interval on all resources set to 10m.

In both scenarios, memory improvements could be observed but the most significant ones were observed during scenario 2 (as can be expected based on the changes.

Scenario 1

Before

Scenario 1: before

After

Scenario 1: after

Scenario 2

Before

Scenario 2: before

After

Scenario 2: after

@hiddeco
Copy link
Member

hiddeco commented Aug 2, 2023

Improvement for scenario 2 is actually much better, as the memory consumption got suppressed by throttling of CPU. Actual consumption (while still running into CPU throttling) is more like this:

Scenario 2: before take 2

@somtochiama somtochiama marked this pull request as ready for review August 2, 2023 15:37
internal/helm/repository/chart_repository.go Outdated Show resolved Hide resolved
internal/helm/repository/chart_repository_test.go Outdated Show resolved Hide resolved
}
]
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Newline.

@hiddeco hiddeco requested a review from darkowlzz August 2, 2023 15:57
Comment on lines 479 to 480
// `sigs.k8s.io/yaml` package to unmarshal the YAML data.
// Copied from https://github.com/helm/helm/blob/2544aa23a33977d91fe8f59d12dd923dc43be6c5/pkg/repo/index.go#L378-L390
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// `sigs.k8s.io/yaml` package to unmarshal the YAML data.
// Copied from https://github.com/helm/helm/blob/2544aa23a33977d91fe8f59d12dd923dc43be6c5/pkg/repo/index.go#L378-L390
// `sigs.k8s.io/yaml` package to unmarshal the YAML data.
//
// Can potentially be replaced when Helm PR for JSON support has been merged.
// xref: https://github.com/helm/helm/pull/12245

@@ -401,6 +402,15 @@ func (r *ChartRepository) Digest(algorithm digest.Algorithm) digest.Digest {
return r.digests[algorithm]
}

// ToJSON returns the index formatted as JSON
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// ToJSON returns the index formatted as JSON
// ToJSON returns the index formatted as JSON.

@hiddeco
Copy link
Member

hiddeco commented Aug 4, 2023

@somtochiama can you please squash your commits?

Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

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

LGTM, but would prefer another +1 before this gets merged.

Thank you @somtochiama 🙇 🥇

@hiddeco hiddeco requested a review from darkowlzz August 7, 2023 11:21
Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

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

LGTM!

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
@hiddeco hiddeco merged commit 63f4060 into fluxcd:main Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm Helm related issues and pull requests enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store Helm repository indexes in JSON format
3 participants