Skip to content

Remove redundant enclosing lock from BalanceCache - #18

Open
syjn99 wants to merge 1 commit into
developfrom
fix/remove-lru-lock-active-balance
Open

Remove redundant enclosing lock from BalanceCache#18
syjn99 wants to merge 1 commit into
developfrom
fix/remove-lru-lock-active-balance

Conversation

@syjn99

@syjn99 syjn99 commented Mar 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Removed redundant sync.RWMutex from BalanceCache struct in beacon-chain/cache/active_balance.go
  • The underlying hashicorp/golang-lru cache already provides internal thread-safe locking, making the external lock unnecessary overhead
  • Removed all c.lock.Lock()/Unlock()/RLock()/RUnlock() calls from Clear(), AddTotalEffectiveBalance(), and Get()
  • Removed unused sync import

Closes OffchainLabs#13723

Test plan

  • gofmt and goimports pass
  • Gazelle BUILD sync passes
  • bazel build //beacon-chain/cache/... passes
  • bazel test //beacon-chain/cache/... passes (2/2 tests pass, no regressions)

🤖 Generated with Claude Code

The BalanceCache struct wraps hashicorp/golang-lru which already has
internal locking. The external sync.RWMutex is redundant and adds
unnecessary overhead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@syjn99
syjn99 force-pushed the fix/remove-lru-lock-active-balance branch from 2b14546 to 28b3a08 Compare March 4, 2026 18:04
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.

Remove enclosing locks from lru caches

1 participant