Skip to content

Conversation

turbolent
Copy link
Member

Merge master into the Cadence VM feature branch based on master, feature/cadence-vm.

fxamacker and others added 30 commits July 16, 2025 21:18
Currently, some memory caches that use concatenated IDs, etc., as keys
can contain items that were already deleted from the database.

For use cases where we know the exact key to be deleted, the problem
was already solved by flow-go#7324 and delete-by-key is fast enough
(it is the max possible delete speed of hashicorp/golang-lru).

Unfortunately, deleting a set of keys without knowing the exact
keys to delete would be too slow, especially as the cache size
grows. As an added risk, the cache size is configurable by flag.

This commit uses the new GroupCache LRU created for deleting group
of keys at the max speed of hashicorp/golang-lru when we only
have the prefix that would match the keys we want to delete.

GroupCache is a new LRU that was created for this use case at
github.com/fxamacker/golang-lru

GroupCache retains the fast speed of Get while also allowing the
delete-by-group performance to be relatively stable even as number of
total items in the cache grows. The trade-off is to use some extra
memory (cached keys).

Previously, using the old approach of using RemoveFunc would
be roughly 2x slower than delete-by-key and become even
slower than that if the cache size is larger.

GroupCache is only about 17% slower than delete-by-key (the
max possible speed) when deleting 5,000 keys in groups of 5
(i.e., each key prefix matching 5 keys).

delete-by-key  delete-by-group
697.1µ ± 11%   814.7µ ± 1%      +16.86% (p=0.000 n=20)

These benchmarks show GroupCache does not slow down when
deleting keys by group as cache size grows.

cache_size_1,000    8565 ns/op
cache_size_2,000    9709 ns/op
cache_size_3,000    9451 ns/op
cache_size_4,000   10370 ns/op
cache_size_5,000   10073 ns/op
cache_size_10,000   8268 ns/op

These results are very preliminary and may change.
NOTE: GroupCache will require extra memory (to hold keys).
zhangchiqing and others added 24 commits October 1, 2025 17:02
Co-authored-by: Alexander Hentschel <[email protected]>
Refactor notifier_test to use synctest
[ExecutionData] Update lz4 compression library
@turbolent turbolent requested a review from j1010001 October 3, 2025 20:44
@turbolent turbolent requested a review from a team as a code owner October 3, 2025 20:44
@turbolent turbolent requested a review from a team October 3, 2025 20:44
@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 0% with 44 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
integration/benchmark/mock/client.go 0.00% 44 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.