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

framework/config,server: configkey caching #9628

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

shwstppr
Copy link
Contributor

@shwstppr shwstppr commented Sep 3, 2024

Description

Added caching for ConfigKey value retrievals based on the Caffeine in-memory caching library.
https://github.com/ben-manes/caffeine
Currently, expire time for a cache is 30s and each update of the config key invalidates the cache. On any update or reset of the configuration, the cache automatically invalidates for it.

This useful when there are concurrent operations as it will prevent multiple DB queries within a short span of time.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 41.66667% with 42 lines in your changes missing coverage. Please review.

Project coverage is 15.58%. Comparing base (0692a29) to head (a890b6a).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
...udstack/framework/config/impl/ConfigDepotImpl.java 63.88% 11 Missing and 2 partials ⚠️
.../cloud/configuration/ConfigurationManagerImpl.java 0.00% 7 Missing ⚠️
.../apache/cloudstack/framework/config/ConfigKey.java 58.33% 5 Missing ⚠️
...ava/com/cloud/domain/dao/DomainDetailsDaoImpl.java 0.00% 3 Missing ⚠️
...ain/java/com/cloud/user/AccountDetailsDaoImpl.java 0.00% 3 Missing ⚠️
...oudstack/framework/config/ScopedConfigStorage.java 0.00% 3 Missing ⚠️
.../main/java/com/cloud/dc/ClusterDetailsDaoImpl.java 0.00% 2 Missing ⚠️
...ava/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java 0.00% 2 Missing ⚠️
...m/cloud/storage/dao/StoragePoolDetailsDaoImpl.java 0.00% 2 Missing ⚠️
...storage/datastore/db/ImageStoreDetailsDaoImpl.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               main    #9628    +/-   ##
==========================================
  Coverage     15.57%   15.58%            
- Complexity    12049    12054     +5     
==========================================
  Files          5505     5506     +1     
  Lines        482635   482694    +59     
  Branches      61701    60954   -747     
==========================================
+ Hits          75187    75211    +24     
- Misses       399141   399176    +35     
  Partials       8307     8307            
Flag Coverage Δ
uitests 4.16% <ø> (-0.01%) ⬇️
unittests 16.36% <41.66%> (+<0.01%) ⬆️

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

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

Copy link
Member

@rohityadavcloud rohityadavcloud left a comment

Choose a reason for hiding this comment

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

LGTM - real world tests may be necessary, or a smoketests on test matrix.

Added caching for ConfigKey value retrievals based on the Caffeine
in-memory caching library.
https://github.com/ben-manes/caffeine
Currently, expire time for a cache is 30s and each update of the
config key invalidates the cache. On any update or reset of the
configuration, cache automatically invalidates for it.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr
Copy link
Contributor Author

shwstppr commented Sep 3, 2024

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10930

@shwstppr
Copy link
Contributor Author

shwstppr commented Sep 3, 2024

@blueorangutan test

@blueorangutan
Copy link

@shwstppr a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@rohityadavcloud rohityadavcloud marked this pull request as ready for review September 4, 2024 06:56
@blueorangutan
Copy link

[SF] Trillian test result (tid-11317)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 48173 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9628-t11317-kvm-ol8.zip
Smoke tests completed. 139 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

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

good improvement !

Copy link
Contributor

@Pearl1594 Pearl1594 left a comment

Choose a reason for hiding this comment

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

Code LGTM. Just a couple of queries.


private HashMap<String, Pair<String, ConfigKey<?>>> _allKeys = new HashMap<String, Pair<String, ConfigKey<?>>>(1007);

HashMap<ConfigKey.Scope, Set<ConfigKey<?>>> _scopeLevelConfigsMap = new HashMap<ConfigKey.Scope, Set<ConfigKey<?>>>();

public ConfigDepotImpl() {
configCache = Caffeine.newBuilder()
Copy link
Member

Choose a reason for hiding this comment

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

Minor - in the next iteration, could we move/refactor caching library object creation & configuration to a separate class/utility/framework; so users only need to import & call the method to get the Cache objects/entities, but configuration etc are in that utility - making it easier to change the caching library in future. Otherwise LGTM, thanks @shwstppr

@rohityadavcloud rohityadavcloud merged commit 31b0ed0 into apache:main Sep 5, 2024
26 checks passed
@rohityadavcloud rohityadavcloud deleted the add-configkey-caching branch September 5, 2024 04:02
shwstppr added a commit to shapeblue/cloudstack that referenced this pull request Sep 5, 2024
Follow up for apache#9628
Creates a utility class LazyCache which currently wraps Caffeine library Cache class.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
shwstppr added a commit to shapeblue/cloudstack that referenced this pull request Sep 5, 2024
Follow up from apache#9628 (comment)

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
shwstppr added a commit to shapeblue/cloudstack that referenced this pull request Sep 5, 2024
Follow up from apache#9628 (comment)

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Sep 6, 2024
Added caching for ConfigKey value retrievals based on the Caffeine
in-memory caching library.
https://github.com/ben-manes/caffeine
Currently, expire time for a cache is 30s and each update of the
config key invalidates the cache. On any update or reset of the
configuration, cache automatically invalidates for it.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
shwstppr added a commit to shwstppr/cloudstack that referenced this pull request Oct 1, 2024
Follow up for apache#9628
Creates a utility class LazyCache which currently wraps Caffeine library Cache class.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants