Skip to content
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

Add cache to block window #1948

Merged
merged 8 commits into from
Feb 20, 2022
Merged

Conversation

someone235
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #1948 (08d6735) into dev (28d0f1e) will increase coverage by 0.04%.
The diff coverage is 81.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1948      +/-   ##
==========================================
+ Coverage   61.06%   61.11%   +0.04%     
==========================================
  Files         640      643       +3     
  Lines       30034    30155     +121     
==========================================
+ Hits        18341    18428      +87     
- Misses       9095     9114      +19     
- Partials     2598     2613      +15     
Impacted Files Coverage Δ
.../consensus/processes/dagtraversalmanager/window.go 69.23% <69.35%> (-2.65%) ⬇️
...licestore/block_window_heap_slice_staging_shard.go 87.50% <87.50%> (ø)
...dowheapslicestore/block_window_heap_slice_store.go 87.50% <87.50%> (ø)
...hehashandwindowsizetoblockghostdagdatahashpairs.go 89.18% <89.18%> (ø)
domain/consensus/factory.go 93.62% <100.00%> (+0.02%) ⬆️
...sensus/processes/dagtraversalmanager/block_heap.go 86.00% <100.00%> (+1.38%) ⬆️
...ocesses/dagtraversalmanager/dagtraversalmanager.go 78.33% <100.00%> (+0.36%) ⬆️
infrastructure/network/rpcclient/rpc_get_info.go 45.45% <0.00%> (-18.19%) ⬇️
app/protocol/flows/v4/blockrelay/block_locator.go 52.94% <0.00%> (-11.77%) ⬇️
infrastructure/network/rpcclient/rpcclient.go 60.67% <0.00%> (-6.75%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28d0f1e...08d6735. Read the comment docs.

@@ -45,6 +67,37 @@ func (dtm *dagTraversalManager) calculateBlockWindowHeap(stagingArea *model.Stag
return nil, err
}

_, err = dtm.daaWindowStore.DAAWindowBlock(dtm.databaseContext, stagingArea, current, 0)
isNotFoundError := database.IsNotFoundError(err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe rename isNotFoundError to isNonTrustedBlock

@@ -45,6 +67,37 @@ func (dtm *dagTraversalManager) calculateBlockWindowHeap(stagingArea *model.Stag
return nil, err
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Explain in a comment why blocks which are with trusted data should not use cache of selected parent (mergeset might be missing?)


if isNotFoundError && currentGHOSTDAGData.SelectedParent() != nil {
windowHeapSlice, err := dtm.windowHeapSliceStore.Get(stagingArea, highHash, windowSize)
isNotFoundError := database.IsNotFoundError(err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe rename isNotFoundError to selectedParentNotCached

}

if isNotFoundError && currentGHOSTDAGData.SelectedParent() != nil {
windowHeapSlice, err := dtm.windowHeapSliceStore.Get(stagingArea, highHash, windowSize)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like highHash is an error, shouldn't it be currentGHOSTDAGData.SelectedParent() ? (the comment two lines below assumes that as well)

func (dtm *dagTraversalManager) blockWindowHeap(stagingArea *model.StagingArea,
highHash *externalapi.DomainHash, windowSize int) (*sizedUpBlockHeap, error) {
windowHeapSlice, err := dtm.windowHeapSliceStore.Get(stagingArea, highHash, windowSize)
isNotFoundError := database.IsNotFoundError(err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps rename isNotFoundError to sliceNotCached. In general the name isNotFoundError is confusing also in the method below, I would avoid it

@someone235 someone235 merged commit 1c18a49 into kaspanet:dev Feb 20, 2022
@someone235 someone235 deleted the block-window-cache branch February 20, 2022 15:37
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.

2 participants