kv-client: use multiple sync.Map to reduce lock contention (#1439) #1476
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cherry-pick #1439 to release-4.0
You can switch your code base to this Pull Request by using git-extras:
# In ticdc repo: git pr https://github.com/pingcap/ticdc/pull/1476
After apply modifications, you can push your change to this PR via:
What problem does this PR solve?
part 3 of #1393, please review this PR after #1426 is merged
sync.Map
is faster than RWMutex and Mutex. Note this is concluded from some benchmarks, such as sync: RWMutex scales poorly with CPU count golang/go#17973, https://www.jianshu.com/p/cffffa914381, but maybe not quite suitable for our scene, we need more tests for this point, the most important thing here is to simulate the real world workload.sync.Map
can accelerate map accessWhat is changed and how it works?
sync.Map
s for regionFeedState get/put operation.sync.Map
pool is determined by cpu number, min threshold, and max thresholdCheck List
Tests
Release note