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

Add a new Sizeable interface in cadence common cache #6679

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

timl3136
Copy link
Member

@timl3136 timl3136 commented Feb 19, 2025

What changed?
Add a new Sizeable interface that implements Size() function which returns the size of that interface in bytes

Why?
We want to modernize existing cadence common cache implement to a bytes-based system. That means we need to have a method to measure each entry (which is currently accepting any generic interface). We found the "Reflect" package provides a measuring function but runtime is too slow to be used in cache operations. Therefore, we will require all usages to implement the Size() function in their cache logic if they want to migrate to the new bytes-based system.

In order to seamless transition from the current cache system with an entry-based model, the implementation and rollout will be done in following phases:

  1. Define the Sizeable interface <-- This PR
  2. Implement Sizeable for cadence-history service
    a. Implement Size() for ExecutionCache
    b. Implement Size() for EventCache
  3. Implement bytes-based cache system
  4. Enable new cache system for usage in cadence-history service
  5. Implement and enable new cache system for the remaining usages

How did you test it?
This is only an addition of a new interface that is not used.

Potential risks
No risk since it's only an addition of a new interface that is not used.

Release notes

Documentation Changes

@3vilhamster
Copy link
Contributor

Size() int is already provided by cache.Cache and is supplied by lru type.
Maybe we can use a different name? Or change the existing Size to Len? I think having two different functions for Size can be confusing.

@taylanisikdemir
Copy link
Member

taylanisikdemir commented Feb 19, 2025

Size() int is already provided by cache.Cache and is supplied by lru type. Maybe we can use a different name? Or change the existing Size to Len? I think having two different functions for Size can be confusing.

This is for size of the entries

@timl3136 timl3136 merged commit e8da0e9 into cadence-workflow:master Feb 21, 2025
22 checks passed
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.

3 participants