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

[Chunk Data Pack] Refactor Chunk data packs modules to use generic storage interface #6892

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

zhangchiqing
Copy link
Member

@zhangchiqing zhangchiqing commented Jan 15, 2025

This PR refactors the chunk data packs modules to use the generic storage interfaces. This allows us to reuse functions that made for the generic storage interface to be used on chunk data packs when implementing chunk data pack pruner.

Since chunk data packs are stored in pebble now, this PR also fixed some test cases and tools that was still dealing with chunk data packs stored in badger.

@@ -60,18 +69,28 @@ func run(*cobra.Command, []string) {
metrics := &metrics.NoopCollector{}
transactionResults := badger.NewTransactionResults(metrics, db, badger.DefaultCacheSize)
commits := badger.NewCommits(metrics, db)
chunkDataPacks := badger.NewChunkDataPacks(metrics, db, badger.NewCollections(db, badger.NewTransactions(metrics, db)), badger.DefaultCacheSize)
Copy link
Member Author

Choose a reason for hiding this comment

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

The previous implementation was wrong. Since we have moved chunk data packs to pebble, we should use pebble based chunk data packs module for rolling executed height.

headers := bstorage.NewHeaders(metrics, db)
txResults := bstorage.NewTransactionResults(metrics, db, bstorage.DefaultCacheSize)
commits := bstorage.NewCommits(metrics, db)
chunkDataPacks := store.NewChunkDataPacks(metrics, pebbleimpl.ToDB(pdb), bstorage.NewCollections(db, bstorage.NewTransactions(metrics, db)), bstorage.DefaultCacheSize)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the actual change.

Comment on lines +118 to +120
require.NoError(t, err)
require.NoError(t, chunkBatch.Commit())
err2 := batch.Flush()
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the actual change.

Comment on lines +242 to +245
require.NoError(t, err)
require.NoError(t, chunkBatch.Commit())
err2 := batch.Flush()
require.NoError(t, err2)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the actual change.

@@ -0,0 +1,24 @@
package operation
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved from storage/pebble/operation/chunk_data_packs.go

@@ -0,0 +1,133 @@
package store_test
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved from storage/pebble/chunk_data_packs_test.go

@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 37.76824% with 145 lines in your changes missing coverage. Please review.

Project coverage is 41.09%. Comparing base (0d2b34f) to head (ef20e53).
Report is 53 commits behind head on master.

Files with missing lines Patch % Lines
storage/mock/batch.go 0.00% 46 Missing ⚠️
storage/mock/db.go 0.00% 44 Missing ⚠️
storage/store/cache.go 70.27% 21 Missing and 1 partial ⚠️
...ck-executed-height/cmd/rollback_executed_height.go 21.73% 18 Missing ⚠️
storage/store/chunk_data_packs.go 75.75% 5 Missing and 3 partials ⚠️
cmd/execution_builder.go 0.00% 2 Missing ⚠️
engine/verification/verifier/verifiers.go 0.00% 2 Missing ⚠️
storage/mock/chunk_data_packs.go 0.00% 2 Missing ⚠️
engine/testutil/nodes.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6892      +/-   ##
==========================================
- Coverage   41.11%   41.09%   -0.02%     
==========================================
  Files        2116     2118       +2     
  Lines      185737   185840     +103     
==========================================
+ Hits        76368    76374       +6     
- Misses     102952   103065     +113     
+ Partials     6417     6401      -16     
Flag Coverage Δ
unittests 41.09% <37.76%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@zhangchiqing zhangchiqing marked this pull request as ready for review January 15, 2025 21:24
@zhangchiqing zhangchiqing requested a review from a team as a code owner January 15, 2025 21:24
Copy link
Contributor

@peterargue peterargue left a comment

Choose a reason for hiding this comment

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

looks good

@@ -11,9 +11,6 @@ const (
//lint:ignore U1000 Ignore unused variable warning
// job queue consumers and producers
codeJobConsumerProcessed = 70

// legacy codes (should be cleaned up)
codeChunkDataPack = 100
Copy link
Contributor

Choose a reason for hiding this comment

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

should this code be reserved for some period of time?

Copy link
Member Author

Choose a reason for hiding this comment

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

If reserving is to reverting the changes, I would revert by reverting the whole feature branch, rather than doing at the code level.

So I think it's OK to just clean up

@zhangchiqing zhangchiqing force-pushed the leo/storage-refactor-chunk-data-packs branch from 5c8a3a5 to c2cd930 Compare January 22, 2025 00:00
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.

3 participants