Skip to content

*: fix cache cpu load - #4295

Merged
obol-bulldozer[bot] merged 59 commits into
mainfrom
kalo/fix-cache-cpu-load
Feb 9, 2026
Merged

obol-bulldozer[bot] merged 59 commits into
mainfrom
kalo/fix-cache-cpu-load

Conversation

@KaloyanTanev

@KaloyanTanev KaloyanTanev commented Feb 6, 2026 •

Copy link
Copy Markdown
Collaborator

We have experienced CPU spikes with the new cache logic, even when turning on the disable_duties_cache feature flag.

The fix was to include the metadata of the BN request to the response to the VC. However, I've used the occasion to rework and improve other parts of the cache (and not only):

  1. Use separate locks for the 3 types of duties cache and validators cache
  2. Save the eth2resp metadata in the cache as well
  3. Keep the lock for smaller period of time
  4. Rework the feature flag locking to be RW lock

category: bug
ticket: #4009

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Implements a duties caching refactor intended to reduce duplicate BN duties requests (issue #4009) and CPU/load by consolidating duties caching behavior behind eth2wrap.DutiesCache, with a safety feature flag to disable caching.

Changes:

  • Add featureset.DisableDutiesCache branching to optionally bypass duties cache and call upstream BN duties endpoints directly.
  • Refactor eth2wrap.DutiesCache internal storage/locking and remove UpdateCacheIndices plumbing.
  • Update scheduler/tracker/validatorapi call sites and wiring to match the new cache behavior and feature-flag gating.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
core/validatorapi/validatorapi.go Adds feature-flag branch for duties cache usage and adjusts duty pubkey substitution.
core/tracker/inclusion.go Skips inclusion checks when feature is disabled; adds feature-flag branch for attester duties cache usage.
core/scheduler/scheduler.go Adds feature-flag branch to use cached vs upstream duties calls for attester/proposer/sync duties.
app/vmock.go Updates duties cache constructor usage to new signature.
app/featureset/featureset.go Switches feature state guard to RWMutex and uses read locks for readers.
app/eth2wrap/multi_test.go Removes tests for UpdateCacheIndices forwarding.
app/eth2wrap/multi.go Removes UpdateCacheIndices forwarding implementation.
app/eth2wrap/lazy_test.go Removes tests for UpdateCacheIndices forwarding.
app/eth2wrap/lazy.go Removes UpdateCacheIndices forwarding implementation.
app/eth2wrap/httpwrap.go Splits cache locking into separate mutexes for validator and duties caches; removes no-op UpdateCacheIndices.
app/eth2wrap/cache_test.go Updates duties cache constructor usage to new signature.
app/eth2wrap/cache.go Major refactor of duties cache storage/locking and cache trim/invalidation behavior.
app/app.go Wires duties cache only when enabled; removes UpdateCacheIndices update path; trims duties cache on epoch boundary.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/validatorapi/validatorapi.go Resolved
Comment thread app/eth2wrap/httpwrap.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread core/validatorapi/validatorapi.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
@codecov

codecov Bot commented Feb 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 35.93315% with 230 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.52%. Comparing base (bfc2739) to head (f233d9a).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
app/eth2wrap/cache.go 36.00% 123 Missing and 5 partials ⚠️
core/validatorapi/validatorapi.go 55.17% 20 Missing and 6 partials ⚠️
app/eth2wrap/httpwrap.go 0.00% 24 Missing ⚠️
core/scheduler/scheduler.go 42.42% 14 Missing and 5 partials ⚠️
core/tracker/inclusion.go 0.00% 14 Missing ⚠️
app/app.go 0.00% 10 Missing ⚠️
app/eth2wrap/lazy.go 50.00% 3 Missing ⚠️
app/eth2wrap/synthproposer.go 0.00% 3 Missing ⚠️
app/featureset/featureset.go 50.00% 2 Missing ⚠️
app/vmock.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4295      +/-   ##
==========================================
- Coverage   56.61%   56.52%   -0.09%     
==========================================
  Files         237      237              
  Lines       31360    31471     +111     
==========================================
+ Hits        17753    17789      +36     
- Misses      11333    11397      +64     
- Partials     2274     2285      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

KaloyanTanev and others added 4 commits February 6, 2026 19:09
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: kalo <24719519+KaloyanTanev@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: kalo <24719519+KaloyanTanev@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/eth2wrap/cache.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread core/validatorapi/validatorapi.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread app/eth2wrap/cache.go Resolved
Comment thread core/validatorapi/validatorapi.go Resolved
Comment thread core/validatorapi/validatorapi.go Resolved
@KaloyanTanev KaloyanTanev self-assigned this Feb 9, 2026
@KaloyanTanev
KaloyanTanev marked this pull request as ready for review February 9, 2026 16:45
@sonarqubecloud

sonarqubecloud Bot commented Feb 9, 2026

Copy link
Copy Markdown

@KaloyanTanev KaloyanTanev added the merge when ready Indicates bulldozer bot may merge when all checks pass label Feb 9, 2026
@obol-bulldozer
obol-bulldozer Bot merged commit bbf5560 into main Feb 9, 2026
12 checks passed
@obol-bulldozer
obol-bulldozer Bot deleted the kalo/fix-cache-cpu-load branch February 9, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge when ready Indicates bulldozer bot may merge when all checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants