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

memdb: use atomic u64 addr to reduce allocation #1453

Merged
merged 3 commits into from
Aug 28, 2024

Conversation

you06
Copy link
Contributor

@you06 you06 commented Aug 27, 2024

After #1389, we cache the last traversed node in memdb, but it's an atomic pointer, which need a heap allocation every time we update it, so the benchmark has little regression.

go test ./internal/unionstore -v -benchmem -bench=BenchmarkMemDbBufferSequential -run=^a -benchtime=1x

before  #1389
BenchmarkMemDbBufferSequential-8               1          42312917 ns/op        12576704 B/op         31 allocs/op

after #1389
BenchmarkMemDbBufferSequential-8               1          46407916 ns/op        15776704 B/op     200031 allocs/op

this pr
BenchmarkMemDbBufferSequential-8               1          44018167 ns/op        12576704 B/op         31 allocs/op

This PR also fixes some bugs of memdb:

  • The refactor leave a mistake of the snapshot reverse iterator.
  • The cached addr should be reset when memdb is reset.

@ti-chi-bot ti-chi-bot bot added the dco-signoff: yes Indicates the PR's author has signed the dco. label Aug 27, 2024
@you06 you06 requested a review from ekexium August 27, 2024 07:08
@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 27, 2024
internal/unionstore/rbt/rbt.go Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 27, 2024
Signed-off-by: you06 <[email protected]>
@you06
Copy link
Contributor Author

you06 commented Aug 28, 2024

@cfzjywxk PTAL

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 28, 2024
Copy link

ti-chi-bot bot commented Aug 28, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, ekexium

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

ti-chi-bot bot commented Aug 28, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-27 07:27:11.651498102 +0000 UTC m=+855226.785948223: ☑️ agreed by ekexium.
  • 2024-08-28 03:59:13.537259489 +0000 UTC m=+929148.671709610: ☑️ agreed by cfzjywxk.

@ti-chi-bot ti-chi-bot bot merged commit 6b1453c into tikv:master Aug 28, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants