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

Use jemalloc to trace thread allocation #8844

Merged
merged 42 commits into from
Mar 18, 2024

Conversation

CalvinNeo
Copy link
Member

@CalvinNeo CalvinNeo commented Mar 14, 2024

What problem does this PR solve?

Issue Number: close #8835, close #8589

Problem Summary:

  1. WITH_JEMALLOC to enable external-jemalloc
  2. Introduce reportThreadAllocInfo etc.

Basicly two modes:

  1. For everlasting threads, record allocated/deallocated ptr, update according to these ptrs.
  2. For non-everlasting threads, mostly comes from Proxy, update only when the thread is executing something.

We don't directly monitor at FFI boundary because:

  1. There are some threads like raftstore which can't be monitored through FFI boundary.
  2. Rust's thread id does not has a meaning.

See also https://github.com/pingcap/tidb-engine-ext/pull/366/files

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

z
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 14, 2024
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 14, 2024
@CalvinNeo
Copy link
Member Author

image

CalvinNeo and others added 4 commits March 14, 2024 23:19
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
h
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
dbms/src/Storages/KVStore/KVStore.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/KVStore/KVStore.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/KVStore/FFI/ProxyFFI.cpp Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
dbms/src/Common/MemoryTrace.h Outdated Show resolved Hide resolved
CalvinNeo and others added 10 commits March 15, 2024 10:50
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Co-authored-by: Lloyd-Pottiger <60744015+Lloyd-Pottiger@users.noreply.github.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
z
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
f
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
x
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
x
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
x
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
dbms/src/Common/TiFlashMetrics.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/KVStore/KVStore.cpp Outdated Show resolved Hide resolved
dbms/src/Storages/KVStore/KVStore.cpp Outdated Show resolved Hide resolved
dbms/src/Common/TiFlashMetrics.h Outdated Show resolved Hide resolved
CalvinNeo and others added 3 commits March 18, 2024 11:27
Co-authored-by: JaySon <tshent@qq.com>
x
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@@ -0,0 +1,37 @@
// Copyright 2024 PingCAP, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

This filename is easy to confuse with MemoryTracker.cpp.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed into MemoryAllocTracker

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-all-tests

@CalvinNeo
Copy link
Member Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 18, 2024
Copy link
Contributor

ti-chi-bot bot commented Mar 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, JinheLin, Lloyd-Pottiger

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:
  • OWNERS [JaySon-Huang,JinheLin,Lloyd-Pottiger]

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

@CalvinNeo
Copy link
Member Author

[2024-03-18T09:33:57.596Z] 
Stopping fullstack-test_tiflash0_1 ... error

Stopping fullstack-test_tikv0_1    ... error

Stopping fullstack-test_pd0_1      ... error

Stopping fullstack-test_tidb0_1    ... done


[2024-03-18T09:33:57.596Z] ERROR: for fullstack-test_tiflash0_1  cannot stop container: 1f118e0614d4aac39cf246135f74a693a79197d56bb4142de62f0999daa734ca: tried to kill container, but did not receive an exit event

[2024-03-18T09:33:57.596Z] Removing fullstack-test_tidb0_1    ... 

[2024-03-18T09:33:57.596Z] Removing fullstack-test_tiflash0_1 ... 

[2024-03-18T09:33:57.851Z] 
Removing fullstack-test_tidb0_1    ... done

Removing fullstack-test_tiflash0_1 ... done
Removing network fullstack-test_default

[2024-03-18T09:33:57.852Z] error while removing network: network fullstack-test_default id c8d1b8608346fbdb325d6157808b9a71ad112ff4d6223204c15ac087a8c52973 has active endpoints

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-all-tests

Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
@CalvinNeo
Copy link
Member Author

/run-all-tests

@CalvinNeo
Copy link
Member Author

/run-unit-test

@ti-chi-bot ti-chi-bot bot merged commit f061a58 into pingcap:master Mar 18, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support thread-wise memory alloc/dealloc monitor tiflash cn always crash after kill this tiflash cn
4 participants