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

Refactor batch system #223

Merged
merged 4 commits into from
Aug 9, 2019
Merged

Refactor batch system #223

merged 4 commits into from
Aug 9, 2019

Conversation

coocood
Copy link
Collaborator

@coocood coocood commented Aug 8, 2019

The old batch system for multi-thread raft is too complex.
Replace it with a simpler multi-thread model.

@coocood
Copy link
Collaborator Author

coocood commented Aug 8, 2019

Each peer can bind to a worker, and we can bind a peer to another worker if we need to.

Currently, there is no scheduler to rebalance worker, simpler use the region id to bind a worker.

@@ -193,7 +193,7 @@ func NewDefaultConfig() *Config {
ApplyMaxBatchSize: 1024,
ApplyPoolSize: 2,
StoreMaxBatchSize: 1024,
StorePoolSize: 2,
StorePoolSize: 1,
Copy link
Owner

Choose a reason for hiding this comment

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

Why change the default value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For benchmark comparison, forgot to change it back, I will make it configurable.

Copy link
Contributor

@bobotu bobotu left a comment

Choose a reason for hiding this comment

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

LGTM

}

func (pr *peerRouter) get(regionID uint64) *peerState {
pr.mu.RLock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Using RWMutex in this scenario may cause some performance issue? 🤔
We can do some benchmark later.
ref: golang/go#17973

Copy link
Collaborator Author

@coocood coocood Aug 9, 2019

Choose a reason for hiding this comment

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

We can shard the map based on the region ID for lower contention later.

Copy link
Contributor

Choose a reason for hiding this comment

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

sync.Map or some kinds of COW map may also good

@coocood coocood merged commit 0c0cae4 into ngaut:master Aug 9, 2019
@coocood coocood deleted the remove-old-batch branch August 9, 2019 06:04
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