-
Notifications
You must be signed in to change notification settings - Fork 1.5k
execution, db/state: StateCache follow-ups #22159
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
Closed
Closed
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
12d67f6
execution: read-ahead warmup must not clobber fresher StateCache entries
yperbasis e7cbf18
execution/cache: make PutIfAbsent atomic w.r.t. concurrent Put
yperbasis d60a1f8
execution/cache: dedup StateCache put wrappers, trim repeated PutIfAb…
yperbasis 2de03de
execution/exec: fix negative-caching comment — empty code is not cached
yperbasis f1a99b5
execution/types/accounts: add targeted DeserialiseV3CodeHash extractor
yperbasis 5121282
execution/cache: stripe Delete/stale-drop, liveness pre-checks, warmu…
yperbasis ec75f7a
execution/exec: skip live-binding prefetch work, stamp negatives with…
yperbasis 5a143b8
db/state/execctx: if-absent read-fill, in-flight-unwind assert fix, f…
yperbasis 2fe8e68
execution/execmodule: drain and clear the state cache before ProcessF…
yperbasis 98f4849
Merge remote-tracking branch 'origin/main' into yperbasis/statecache-…
yperbasis 4f99e38
execution/exec: raise the warmup gauge only after warmWg.Add
yperbasis 6622377
Merge remote-tracking branch 'origin/main' into yperbasis/statecache-…
yperbasis 464dde1
execution/cache: swap-then-migrate jump-grow so striped writes surviv…
yperbasis 561b29d
db/state/execctx: tombstone deleted keys in the flush cache-apply
yperbasis a8e81b5
db/state/execctx, execution/exec: trim code-negative warmup work, inl…
yperbasis 044ea9d
execution/cache: freeze writers for the jump-grow copy
yperbasis 1c85ee4
execution/cache, execution/exec: drop the generic ContainsLive probe,…
yperbasis 23bcf56
execution/cache, db/state/execctx, execution/types/accounts: no-code …
yperbasis 9072533
execution/cache: remove Delete — deletions are authoritative nil puts
yperbasis 5324e0b
execution/cache: gofmt
yperbasis 0b2eafc
execution/cache, db/state/execctx, execution/exec, execution/types/ac…
yperbasis 84b146e
execution/exec: skip caching negatives when the warmup getter has no …
yperbasis 8dafd07
Merge remote-tracking branch 'origin/main' into yperbasis/statecache-…
yperbasis 972f75d
Revert "execution/cache: remove Delete — deletions are authoritative …
yperbasis 5317c02
Revert "execution/cache, db/state/execctx, execution/types/accounts: …
yperbasis 69baf33
Revert "db/state/execctx: tombstone deleted keys in the flush cache-a…
yperbasis f3984be
execution/cache: preserve non-tombstone test cleanups
yperbasis bdb650c
Merge branch 'main' into yperbasis/statecache-review-fixes
yperbasis 975ecbb
execution/cache: fence GenericCache.Clear with the put stripes
yperbasis f3f4e57
execution/cache: account currentSize solely via OnEvict
yperbasis bebb2de
execution/cache: document growLRU's unfenced-swap contract
yperbasis 29654fd
execution/exec, execution/execmodule: treat an interrupted read-ahead…
yperbasis 96e6572
execution/exec: bind a warmup's gauge and puts to one launch-time cac…
yperbasis 76f3799
execution/cache: note the transient pre-grow-cap eviction at the grow…
yperbasis d95229c
execution/cache: log jump-grow durations split by unfenced alloc and …
yperbasis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // Copyright 2026 The Erigon Authors | ||
| // This file is part of Erigon. | ||
| // | ||
| // Erigon is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Lesser General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // Erigon is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Lesser General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Lesser General Public License | ||
| // along with Erigon. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| package execctx_test | ||
|
|
||
| import ( | ||
| "encoding/binary" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/erigontech/erigon/common/log/v3" | ||
| "github.com/erigontech/erigon/db/kv" | ||
| "github.com/erigontech/erigon/db/state/execctx" | ||
| ) | ||
|
|
||
| // benchSeedDb commits one account so the domain tables are non-empty for | ||
| // cold-negative probes. | ||
| func benchSeedDb(b *testing.B) kv.TemporalRwDB { | ||
| b.Helper() | ||
| const stepSize = uint64(16) | ||
| ctx := b.Context() | ||
| db := newTestDb(b, stepSize) | ||
|
|
||
| rwTx, err := db.BeginTemporalRw(ctx) | ||
| require.NoError(b, err) | ||
| defer rwTx.Rollback() | ||
| sd, err := execctx.NewSharedDomains(ctx, rwTx, log.New()) | ||
| require.NoError(b, err) | ||
| defer sd.Close() | ||
| written := make([]byte, 20) | ||
| written[0] = 0x01 | ||
| sd.SetTxNum(100) | ||
| require.NoError(b, sd.DomainPut(kv.AccountsDomain, rwTx, written, encAccount(7), 100, nil)) | ||
| require.NoError(b, sd.Commit(ctx, rwTx)) | ||
| return db | ||
| } | ||
|
|
||
| // BenchmarkDomainProgress isolates the negative-stamp source: one | ||
| // files.EndTxNum read plus an MDBX LastKey on the domain's keys table. | ||
| func BenchmarkDomainProgress(b *testing.B) { | ||
| db := benchSeedDb(b) | ||
| roTx, err := db.BeginTemporalRo(b.Context()) | ||
| require.NoError(b, err) | ||
| defer roTx.Rollback() | ||
| b.ResetTimer() | ||
| for i := 0; i < b.N; i++ { | ||
| _ = roTx.Debug().DomainProgress(kv.AccountsDomain) | ||
| } | ||
| } | ||
|
|
||
| // benchColdNegativeReads drives the full cold-negative SD read: the whole | ||
| // miss stack, plus — when a cache is wired — the progress stamp and the | ||
| // if-absent fill. | ||
| func benchColdNegativeReads(b *testing.B, withCache bool) { | ||
| db := benchSeedDb(b) | ||
| ctx := b.Context() | ||
| roTx, err := db.BeginTemporalRo(ctx) | ||
| require.NoError(b, err) | ||
| defer roTx.Rollback() | ||
| sd, err := execctx.NewSharedDomains(ctx, roTx, log.New()) | ||
| require.NoError(b, err) | ||
| defer sd.Close() | ||
| if withCache { | ||
| sd.SetStateCacheForTest(newSmallStateCache()) | ||
| } | ||
|
|
||
| key := make([]byte, 20) | ||
| key[0] = 0x02 | ||
| b.ResetTimer() | ||
| for i := 0; i < b.N; i++ { | ||
| binary.BigEndian.PutUint64(key[12:], uint64(i)+1) | ||
| v, _, err := sd.GetLatest(kv.AccountsDomain, roTx, key) | ||
| if err != nil { | ||
| b.Fatal(err) | ||
| } | ||
| if len(v) != 0 { | ||
| b.Fatalf("expected a negative, got %x", v) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func BenchmarkGetLatestColdNegative(b *testing.B) { benchColdNegativeReads(b, true) } | ||
|
|
||
| // The baseline the stamp+fill cost adds to. | ||
| func BenchmarkGetLatestColdNegativeNoCache(b *testing.B) { benchColdNegativeReads(b, false) } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.