Skip to content

feat: new experimental gc friendly flatten cache #712

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Conversation

rueian
Copy link
Collaborator

@rueian rueian commented Dec 30, 2024

No description provided.

@rueian rueian force-pushed the flatten-cache branch 2 times, most recently from 5f5d6b5 to 8520080 Compare December 31, 2024 06:56
Signed-off-by: Rueian <rueiancsie@gmail.com>
rueian added 7 commits January 5, 2025 10:55
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
@rueian rueian force-pushed the flatten-cache branch 3 times, most recently from 82a112a to c0e7210 Compare February 10, 2025 06:44
Signed-off-by: Rueian <rueiancsie@gmail.com>
@rueian rueian marked this pull request as ready for review February 28, 2025 21:30
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
rueian added 3 commits March 1, 2025 14:15
Signed-off-by: Rueian <rueiancsie@gmail.com>
Signed-off-by: Rueian <rueiancsie@gmail.com>
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Introduces a new experimental GC-friendly flatten cache implementation by adding a time.Time parameter to the Update method signature across the caching system. This change enables better temporal tracking and supports the implementation of a new chained cache structure with improved memory management.

Key changes:

  • Updated Update method signature to include time.Time parameter
  • Added new cache data structures in internal/cache package with optimized memory layout
  • Implemented NewChainedCache as an experimental alternative to the default cache

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pipe_test.go Updated test calls to include time parameter in cache Update method
pipe.go Modified cache Update calls to pass current time
lru_test.go Updated all test cases to use new Update method signature
lru.go Added time parameter to Update method (parameter is unused)
internal/cache/lru_test.go Added comprehensive tests for new LRU double map implementation
internal/cache/lru.go Implemented new LRU double map with GC-friendly design
internal/cache/double_test.go Added tests for new double map data structure
internal/cache/double.go Implemented core double map functionality
internal/cache/chain_test.go Added tests for chain data structure
internal/cache/chain.go Implemented linked chain for hash collision handling
cache_test.go Updated test calls and added test for new flatten cache
cache.go Updated Update method signature and implemented new chained cache
Comments suppressed due to low confidence (1)

lru.go:221

  • [nitpick] The parameter name _ (blank identifier) indicates the time parameter is intentionally unused. Consider using a more descriptive name like now or timestamp for better code readability, even if the parameter is currently unused.
func (c *lru) Update(key, cmd string, value RedisMessage, _ time.Time) (pxat int64) {

m.bp.New = func() any {
e := &empties{s: make([]string, 0, bpsize)}
runtime.SetFinalizer(e, func(e *empties) {
if len(e.s) >= 0 {
Copy link
Preview

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

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

The condition len(e.s) >= 0 is always true since slice length is never negative. This should likely be len(e.s) > 0 to only delete when there are actually entries to process.

Suggested change
if len(e.s) >= 0 {
if len(e.s) > 0 {

Copilot uses AI. Check for mistakes.

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.

1 participant