diff --git a/CHANGELOG.md b/CHANGELOG.md index 19965fccaa..4b76092ad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ ### Improvements - [#1239](https://github.com/crypto-org-chain/cronos/pull/1239) Refactor websocket/subscription system to improve performance and stability. +- [#1241](https://github.com/crypto-org-chain/cronos/pull/1241) Improve parallelization of memiavl restoration. *October 17, 2023* diff --git a/memiavl/import.go b/memiavl/import.go index 6cb245ede5..5634f54d48 100644 --- a/memiavl/import.go +++ b/memiavl/import.go @@ -8,6 +8,8 @@ import ( "path/filepath" ) +const NodeChannelBuffer = 2048 + type MultiTreeImporter struct { dir string snapshotDir string @@ -100,7 +102,7 @@ type TreeImporter struct { } func NewTreeImporter(dir string, version int64) *TreeImporter { - nodesChan := make(chan *ExportNode) + nodesChan := make(chan *ExportNode, NodeChannelBuffer) quitChan := make(chan error) go func() { defer close(quitChan) diff --git a/memiavl/snapshot_test.go b/memiavl/snapshot_test.go index 488a819361..63a11d46e9 100644 --- a/memiavl/snapshot_test.go +++ b/memiavl/snapshot_test.go @@ -179,9 +179,9 @@ func testSnapshotRoundTrip(t *testing.T, db *DB) { require.NoError(t, importer.Add(item)) } - require.NoError(t, exporter.Close()) require.NoError(t, importer.Finalize()) require.NoError(t, importer.Close()) + require.NoError(t, exporter.Close()) db2, err := Load(restoreDir, Options{}) require.NoError(t, err)