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

Feat: optimize list operation for resourcetracker and applicationrevision #5572

Merged
merged 1 commit into from
Feb 27, 2023

Conversation

Somefive
Copy link
Collaborator

@Somefive Somefive commented Feb 27, 2023

Description of your changes

image

When controller handles a large amount of applications, like 50k, the informer cache will hold lots of ResourceTracker and ApplicationRevisions. This will make the list operation on informer cache slow and take lots of CPU.

image

With this optimization, the cache list time consumption can be reduced from 40ms to 25us, and therefore reduce the overall average reconcile time by 50% under the load-testing settings.

The ResourceTracker list operation is introduced since v1.2 but is lost in v1.6 after the code refactor. This PR fixes it and add additional ApplicationRevision list op optimization for it additionally.

The list op optimization is reached by adding field indexer for these two types of resources.

I have:

  • Read and followed KubeVela's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Special notes for your reviewer

@Somefive Somefive marked this pull request as draft February 27, 2023 06:03
@Somefive Somefive force-pushed the feat/optimize-list-op branch 3 times, most recently from ac8e6af to 2f556db Compare February 27, 2023 06:44
@codecov
Copy link

codecov bot commented Feb 27, 2023

Codecov Report

Base: 44.28% // Head: 46.67% // Increases project coverage by +2.38% 🎉

Coverage data is based on head (f80777c) compared to base (af10f11).
Patch coverage: 52.94% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5572      +/-   ##
==========================================
+ Coverage   44.28%   46.67%   +2.38%     
==========================================
  Files         308      254      -54     
  Lines       47795    43438    -4357     
==========================================
- Hits        21167    20274     -893     
+ Misses      23900    20870    -3030     
+ Partials     2728     2294     -434     
Flag Coverage Δ
apiserver-e2etests ?
apiserver-unittests 36.30% <ø> (+0.02%) ⬆️
core-unittests 55.68% <52.94%> (?)
e2e-multicluster-test ?
e2e-rollout-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/core/app/server.go 14.15% <0.00%> (-40.19%) ⬇️
...ller/core.oam.dev/v1alpha2/application/revision.go 61.56% <42.85%> (+5.76%) ⬆️
pkg/resourcetracker/app.go 82.55% <66.66%> (+20.05%) ⬆️
pkg/workflow/workflow.go 0.00% <0.00%> (-100.00%) ⬇️
pkg/apiserver/domain/service/service.go 0.00% <0.00%> (-91.43%) ⬇️
pkg/apiserver/interfaces/api/velaql.go 5.71% <0.00%> (-82.86%) ⬇️
pkg/controller/utils/actions.go 0.00% <0.00%> (-80.00%) ⬇️
pkg/resourcekeeper/containsresources.go 0.00% <0.00%> (-80.00%) ⬇️
pkg/auth/identity.go 0.00% <0.00%> (-76.06%) ⬇️
pkg/apiserver/domain/repository/envbinding.go 0.00% <0.00%> (-72.61%) ⬇️
... and 281 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Somefive Somefive marked this pull request as ready for review February 27, 2023 07:59
@wonderflow wonderflow added backport release-1.6 add this label will automatically backport this PR to release-1.6 branch backport release-1.7 add this label will automatically backport this PR to release-1.7 branch labels Feb 27, 2023
@wonderflow wonderflow changed the title Feat: optimize list op Feat: optimize list operation for resourcetracker and applicationrevision Feb 27, 2023
Copy link
Collaborator

@wonderflow wonderflow left a comment

Choose a reason for hiding this comment

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

please make sure the compatiblity for upgrade case

@Somefive
Copy link
Collaborator Author

please make sure the compatiblity for upgrade case

Compatibility verified.

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
@Somefive Somefive merged commit c023488 into kubevela:master Feb 27, 2023
@github-actions
Copy link

Backport failed for release-1.6, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git fetch origin release-1.6
git worktree add -d .worktree/backport-5572-to-release-1.6 origin/release-1.6
cd .worktree/backport-5572-to-release-1.6
git checkout -b backport-5572-to-release-1.6
ancref=$(git merge-base af10f1122512dd542da9f68da5606d11a18a9867 f80777c4a20c539594c400a8e59ada31ef4eba25)
git cherry-pick -x $ancref..f80777c4a20c539594c400a8e59ada31ef4eba25

@github-actions
Copy link

Backport failed for release-1.7, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git fetch origin release-1.7
git worktree add -d .worktree/backport-5572-to-release-1.7 origin/release-1.7
cd .worktree/backport-5572-to-release-1.7
git checkout -b backport-5572-to-release-1.7
ancref=$(git merge-base af10f1122512dd542da9f68da5606d11a18a9867 f80777c4a20c539594c400a8e59ada31ef4eba25)
git cherry-pick -x $ancref..f80777c4a20c539594c400a8e59ada31ef4eba25

@Somefive Somefive deleted the feat/optimize-list-op branch June 20, 2023 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release-1.6 add this label will automatically backport this PR to release-1.6 branch backport release-1.7 add this label will automatically backport this PR to release-1.7 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants