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

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

Open
ValarDragon opened this issue Jun 26, 2024 · 1 comment
Open

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

ValarDragon opened this issue Jun 26, 2024 · 1 comment
Assignees
Labels
T:feature-request T: Performance Performance improvements

Comments

@ValarDragon
Copy link
Contributor

ValarDragon commented Jun 26, 2024

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()
}
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Cosmos-SDK Jun 26, 2024
@tac0turtle tac0turtle added the T: Performance Performance improvements label Jun 27, 2024
@cool-develope
Copy link
Contributor

great solution 🔥

@tac0turtle tac0turtle moved this from 📋 Backlog to 🤸‍♂️ In Progress in Cosmos-SDK Jul 1, 2024
@tac0turtle tac0turtle moved this from 🤸‍♂️ In Progress to 👀 Waiting / In review in Cosmos-SDK Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T:feature-request T: Performance Performance improvements
Projects
Status: 👀 Waiting / In review
Development

Successfully merging a pull request may close this issue.

3 participants