Skip to content

[Feature]: Run cachemulti.store.write in parallel #20787

Open

Description

Summary

Cachemulti.store.Write calls every constituent CacheKV store's write method. https://github.com/cosmos/cosmos-sdk/blob/main/store/cachemulti/store.go#L122-L128

Now that in SDK v50 onwards we are using working hashes, where these don't directly write to a shared DB, we should switch this to doing every write in a goroutine and having a sync.WaitGroup to wait for all the writes to complete

Problem Definition

Improves an important speed bottleneck in block execution + syncing.

Proposed Feature

Make the code

// Write calls Write on each underlying store.
func (cms Store) Write() {
	cms.db.Write()
        wg := sync.WaitGroup{}
       wg.Add(len(cms.stores))
	for _, store := range cms.stores {
               go func() {
          		store.Write()
          		wg.Done()
               }()
	}
        wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

  • Status

    👀 Waiting / In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions