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

cdc: replace BtreeMap with HashMap in TiCDC #8021

Merged
merged 15 commits into from
Jan 12, 2023

Conversation

overvenus
Copy link
Member

@overvenus overvenus commented Jan 5, 2023

What problem does this PR solve?

Issue Number: ref #7720

What is changed and how it works?

Replace HashMap with BtreeMap in TiCDC, benchmark show hash map is faster in get, insert, and delete, but is slower in range.

cpu: Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz
BenchmarkMap/Get/BtreeMap-40             3258027               398.7 ns/op             0 B/op          0 allocs/op
BenchmarkMap/Get/HashMap-40             11326316               108.1 ns/op             0 B/op          0 allocs/op
BenchmarkMap/Get/SyncMap-40              8013238               141.1 ns/op             0 B/op          0 allocs/op
BenchmarkMap/Store/BtreeMap-40           3021882               434.3 ns/op             0 B/op          0 allocs/op
BenchmarkMap/Store/HashMap-40            8651628               128.3 ns/op             0 B/op          0 allocs/op
BenchmarkMap/Store/SyncMap-40            3344292               412.5 ns/op            71 B/op          2 allocs/op
BenchmarkMap/Delete+Store/BtreeMap-40            1334109               909.3 ns/op             0 B/op          0 allocs/op
BenchmarkMap/Delete+Store/HashMap-40             4777480               239.9 ns/op             0 B/op          0 allocs/op
BenchmarkMap/Delete+Store/SyncMap-40             2168637               561.2 ns/op            71 B/op          2 allocs/op
BenchmarkMap/Range/BtreeMap-40                    825788              1420 ns/op               0 B/op          0 allocs/op
BenchmarkMap/Range/HashMap-40                     210938              4780 ns/op               0 B/op          0 allocs/op
BenchmarkMap/Range/SyncMap-40                     241045              6008 ns/op               0 B/op          0 allocs/op
BenchmarkMap/AscendRange/BtreeMap-40              288669              3933 ns/op               0 B/op          0 allocs/op

Check List

Tests

  • Unit test
  • Integration test

Questions

Will it cause performance regression or break compatibility?

No

Do you need to update user documentation, design documentation or monitoring documentation?

No

Release note

None

@overvenus overvenus added the area/ticdc Issues or PRs related to TiCDC. label Jan 5, 2023
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 5, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • 3AceShowHand
  • sdojjy

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 5, 2023
@overvenus overvenus changed the title cdc: replace HashMap with BtreeMap in TiCDC cdc: replace BtreeMap with HashMap in TiCDC Jan 6, 2023
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus overvenus force-pushed the span-replication/maps branch from 1762a15 to 471f173 Compare January 6, 2023 07:48
@overvenus overvenus marked this pull request as ready for review January 6, 2023 07:49
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 6, 2023
@CharlesCheung96
Copy link
Contributor

Please explain in the pr body why you made this substitution.

@@ -305,7 +305,7 @@ func TestQueryTableCount(t *testing.T) {
m := NewManager(&model.CaptureInfo{ID: "capture-test"}, nil, &liveness, cfg).(*managerImpl)
ctx := context.TODO()
// Add some tables to processor.
tables := spanz.NewMap[tablepb.TablePipeline]()
tables := spanz.NewHashMap[tablepb.TablePipeline]()
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the meaning of the package name spanz?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should be spans (just like the strings package), but it may cause naming confliction, there are so many spans variables. So the name spanz, easy to type and easy to pronounce.

Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
@@ -132,7 +132,7 @@ func (r *redoEventCache) maybeCreateAppender(
func (r *redoEventCache) getAppender(span tablepb.Span) *eventAppender {
r.mu.Lock()
defer r.mu.Unlock()
return r.tables[spanz.ToHashableSpan(span)]
return r.tables.GetV(span)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why define such a method GetV, I think only Get is needed.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 10, 2023
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 11, 2023
@sdojjy
Copy link
Member

sdojjy commented Jan 11, 2023

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 0d1840b

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 11, 2023
@overvenus
Copy link
Member Author

/run-engine-integration-test
/run-verify

@overvenus
Copy link
Member Author

/run-integration-test

@overvenus
Copy link
Member Author

/run-engine-integration-test
/run-dm-integration-test

Signed-off-by: Neil Shen <overvenus@gmail.com>
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Jan 12, 2023
@overvenus
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 5df46fe

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 12, 2023
ti-chi-bot and others added 2 commits January 12, 2023 17:24
Signed-off-by: Neil Shen <overvenus@gmail.com>
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Jan 12, 2023
@overvenus
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 004a28b

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 12, 2023
@overvenus
Copy link
Member Author

/run-engine-integration-test

@ti-chi-bot
Copy link
Member

@overvenus: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

trigger some heavy tests which will not run always when PR updated.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit ad4dc4a into pingcap:master Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ticdc Issues or PRs related to TiCDC. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants