-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Caplin: Optimization and Parallelization of processes and reduction of Goroutines #11058
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
Changes from 15 commits
c32547a
ec8daf0
3039142
cf45d63
df66326
1c9cb8f
83edc38
1fcc8f6
cbd253c
b9509c2
506ee6f
52ad26a
74b0212
3d6d748
9e16f44
3a3968b
be00488
de238a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,7 +190,7 @@ func NewForkGraphDisk(anchorState *state.CachingBeaconState, aferoFs afero.Fs, r | |
| f.lowestAvaiableBlock.Store(anchorState.Slot()) | ||
| f.headers.Store(libcommon.Hash(anchorRoot), &anchorHeader) | ||
|
|
||
| f.dumpBeaconStateOnDisk(anchorState, anchorRoot) | ||
| f.DumpBeaconStateOnDisk(anchorRoot, anchorState, true) | ||
| return f | ||
| } | ||
|
|
||
|
|
@@ -313,12 +313,6 @@ func (f *forkGraphDisk) AddChainSegment(signedBlock *cltypes.SignedBeaconBlock, | |
| BodyRoot: bodyRoot, | ||
| }) | ||
|
|
||
| if newState.Slot()%dumpSlotFrequency == 0 { | ||
| if err := f.dumpBeaconStateOnDisk(newState, blockRoot); err != nil { | ||
| return nil, LogisticError, err | ||
| } | ||
| } | ||
|
|
||
| // Lastly add checkpoints to caches as well. | ||
| f.currentJustifiedCheckpoints.Store(libcommon.Hash(blockRoot), newState.CurrentJustifiedCheckpoint().Copy()) | ||
| f.finalizedCheckpoints.Store(libcommon.Hash(blockRoot), newState.FinalizedCheckpoint().Copy()) | ||
|
|
@@ -361,31 +355,36 @@ func (f *forkGraphDisk) GetState(blockRoot libcommon.Hash, alwaysCopy bool) (*st | |
| blocksInTheWay := []*cltypes.SignedBeaconBlock{} | ||
| // Use the parent root as a reverse iterator. | ||
| currentIteratorRoot := blockRoot | ||
| var copyReferencedState *state.CachingBeaconState | ||
| var err error | ||
| // try and find the point of recconection | ||
| for { | ||
| for copyReferencedState == nil { | ||
| block, isSegmentPresent := f.getBlock(currentIteratorRoot) | ||
| if !isSegmentPresent { | ||
| // check if it is in the header | ||
| bHeader, ok := f.GetHeader(currentIteratorRoot) | ||
| if ok && bHeader.Slot%dumpSlotFrequency == 0 { | ||
| break | ||
| copyReferencedState, err = f.readBeaconStateFromDisk(currentIteratorRoot) | ||
| if err != nil { | ||
| log.Trace("Could not retrieve state: Missing header", "missing", currentIteratorRoot, "err", err) | ||
| } | ||
| continue | ||
|
Giulio2002 marked this conversation as resolved.
|
||
| } | ||
| log.Trace("Could not retrieve state: Missing header", "missing", currentIteratorRoot) | ||
| return nil, nil | ||
| } | ||
| if block.Block.Slot%dumpSlotFrequency == 0 { | ||
| break | ||
| copyReferencedState, err = f.readBeaconStateFromDisk(currentIteratorRoot) | ||
| if err != nil { | ||
| log.Trace("Could not retrieve state: Missing header", "missing", currentIteratorRoot, "err", err) | ||
| } | ||
| if copyReferencedState != nil { | ||
| continue | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would you like to break out loop here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is the same thing, but it is more readable i guess
Giulio2002 marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| blocksInTheWay = append(blocksInTheWay, block) | ||
| currentIteratorRoot = block.Block.ParentRoot | ||
| } | ||
| copyReferencedState, err := f.readBeaconStateFromDisk(currentIteratorRoot) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if copyReferencedState == nil { | ||
| return nil, ErrStateNotFound | ||
| } | ||
|
|
||
| // Traverse the blocks from top to bottom. | ||
| for i := len(blocksInTheWay) - 1; i >= 0; i-- { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.