cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Implement size estimation function for structs used in history event cache

Open timl3136 opened this issue 10 months ago • 0 comments

Still in drafting mode due to git commit is combined with another PR, main change is in the shared.go

What changed? Implement Size() for structs referred in history event cache

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:

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

How did you test it? Unit tests

Potential risks No risk since this PR only adds read-only function that is not used.

Release notes

Documentation Changes

timl3136 avatar Mar 06 '25 12:03 timl3136