Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
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

perfschema: support performance flame-graph by SQL #12986

Merged
merged 10 commits into from Oct 29, 2019
Merged

Conversation

@lonng
Copy link
Member

lonng commented Oct 29, 2019

Signed-off-by: Lonng heng@lonng.org

What problem does this PR solve?

Currently, we need to get the profile file through the HTTP interface, and then convert the profile file into a flame map (for query cpu/memory/mutex/block/allocs/goroutines) through an external tool. This process is very inefficient and cumbersome.

What is changed and how it works?

Use SQL to directly obtain flamegraph to help us improve diagnostic efficiency.
Note: This PR is part of Hackathon 2019 TBSSQL2.0.

select * from performance_schema.tidb_profile_allocs;
select * from performance_schema.tidb_profile_block;
select * from performance_schema.tidb_profile_cpu;
select * from performance_schema.tidb_goroutines;
select * from performance_schema.tidb_profile_memory;
select * from performance_schema.tidb_profile_mutex;

eg:

mysql> select * from performance_schema.tidb_profile_memory;
+-------------------------------------------------------------------------------------------------------------------+-------------+-------------+------------+-------+------------------------------------------------------------------------------------------------------+
| FUNCTION                                                                                                          | PERCENT_ABS | PERCENT_REL | ROOT_CHILD | DEPTH | FILE                                                                                                 |
+-------------------------------------------------------------------------------------------------------------------+-------------+-------------+------------+-------+------------------------------------------------------------------------------------------------------+
| root                                                                                                              | 100%        | 100%        |          0 |     0 | root                                                                                                 |
| ├─runtime.main                                                                                                    | 66.66%      | 66.66%      |          1 |     1 | runtime/proc.go:203                                                                                  |
| │ ├─main.main                                                                                                     | 61.93%      | 92.91%      |          1 |     2 | github.com/pingcap/tidb@/tidb-server/main.go:176                                                     |
| │ │ ├─main.createStoreAndDomain                                                                                   | 19.51%      | 31.50%      |          1 |     3 | github.com/pingcap/tidb@/tidb-server/main.go:238                                                     |
| │ │ │ └─github.com/pingcap/tidb/session.BootstrapSession                                                          | 19.51%      | 100%        |          1 |     4 | github.com/pingcap/tidb@/session/session.go:1579                                                     |
| │ │ │   └─github.com/pingcap/tidb/session.createSession                                                           | 19.51%      | 100%        |          1 |     5 | github.com/pingcap/tidb@/session/session.go:1670                                                     |
| │ │ │     └─github.com/pingcap/tidb/session.(*domainMap).Get                                                      | 19.51%      | 100%        |          1 |     6 | github.com/pingcap/tidb@/session/tidb.go:70                                                          |
| │ │ │       └─github.com/pingcap/tidb/util.RunWithRetry                                                           | 19.51%      | 100%        |          1 |     7 | github.com/pingcap/tidb@/util/misc.go:46                                                             |
| │ │ │         └─github.com/pingcap/tidb/session.(*domainMap).Get.func1                                            | 19.51%      | 100%        |          1 |     8 | github.com/pingcap/tidb@/session/tidb.go:78                                                          |
| │ │ │           ├─github.com/pingcap/tidb/domain.(*Domain).Init                                                   | 4.69%       | 24.06%      |          1 |     9 | github.com/pingcap/tidb@/domain/domain.go:604                                                        |
| │ │ │           │ └─github.com/pingcap/tidb/infoschema/perfschema.Init                                            | 4.69%       | 100%        |          1 |    10 | github.com/pingcap/tidb@/infoschema/perfschema/init.go:69                                            |
| │ │ │           │   └─sync.(*Once).Do                                                                             | 4.69%       | 100%        |          1 |    11 | sync/once.go:57                                                                                      |
| │ │ │           │     └─sync.(*Once).doSlow                                                                       | 4.69%       | 100%        |          1 |    12 | sync/once.go:66                                                                                      |
| │ │ │           │       └─github.com/pingcap/tidb/infoschema/perfschema.Init.func1                                | 4.69%       | 100%        |          1 |    13 | github.com/pingcap/tidb@/infoschema/perfschema/init.go:49                                            |
| │ │ │           │         └─github.com/pingcap/tidb/ddl.BuildTableInfoFromAST                                     | 4.69%       | 100%        |          1 |    14 | github.com/pingcap/tidb@/ddl/ddl_api.go:1282                                                         |
| │ │ │           │           └─github.com/pingcap/tidb/ddl.buildTableInfoWithCheck                                 | 4.69%       | 100%        |          1 |    15 | github.com/pingcap/tidb@/ddl/ddl_api.go:1314                                                         |
| │ │ │           │             └─github.com/pingcap/tidb/ddl.buildColumnsAndConstraints                            | 4.69%       | 100%        |          1 |    16 | github.com/pingcap/tidb@/ddl/ddl_api.go:269                                                          |
| │ │ │           │               └─github.com/pingcap/tidb/ddl.buildColumnAndConstraint                            | 4.69%       | 100%        |          1 |    17 | github.com/pingcap/tidb@/ddl/ddl_api.go:404                                                          |
| │ │ │           │                 └─github.com/pingcap/tidb/ddl.columnDefToCol                                    | 4.69%       | 100%        |          1 |    18 | github.com/pingcap/tidb@/ddl/ddl_api.go:489                                                          |
| │ │ │           └─github.com/pingcap/tidb/domain.(*Domain).Init                                                   | 14.81%      | 75.94%      |          1 |     9 | github.com/pingcap/tidb@/domain/domain.go:642                                                        |
| │ │ │             └─github.com/pingcap/tidb/ddl.NewDDL                                                            | 14.81%      | 100%        |          1 |    10 | github.com/pingcap/tidb@/ddl/ddl.go:355                                                              |
| │ │ │               └─github.com/pingcap/tidb/ddl.newDDL                                                          | 14.81%      | 100%        |          1 |    11 | github.com/pingcap/tidb@/ddl/ddl.go:396                                                              |
| │ │ │                 └─github.com/pingcap/tidb/ddl.(*ddl).start                                                  | 14.81%      | 100%        |          1 |    12 | github.com/pingcap/tidb@/ddl/ddl.go:440                                                              |
| │ │ │                   └─github.com/pingcap/tidb/ddl.(*ddl).newDeleteRangeManager                                | 14.81%      | 100%        |          1 |    13 | github.com/pingcap/tidb@/ddl/ddl.go:416                                                              |
| │ │ │                     └─github.com/pingcap/tidb/ddl.newDelRangeManager                                        | 14.81%      | 100%        |          1 |    14 | github.com/pingcap/tidb@/ddl/delete_range.go:78                                                      |
| │ │ └─main.createStoreAndDomain                                                                                   | 42.43%      | 68.50%      |          1 |     3 | github.com/pingcap/tidb@/tidb-server/main.go:235                                                     |
| │ │   └─github.com/pingcap/tidb/store.New                                                                         | 42.43%      | 100%        |          1 |     4 | github.com/pingcap/tidb@/store/store.go:51                                                           |
| │ │     └─github.com/pingcap/tidb/store.newStoreWithRetry                                                         | 42.43%      | 100%        |          1 |     5 | github.com/pingcap/tidb@/store/store.go:67                                                           |
| │ │       └─github.com/pingcap/tidb/util.RunWithRetry                                                             | 42.43%      | 100%        |          1 |     6 | github.com/pingcap/tidb@/util/misc.go:46                                                             |
| │ │         └─github.com/pingcap/tidb/store.newStoreWithRetry.func1                                               | 42.43%      | 100%        |          1 |     7 | github.com/pingcap/tidb@/store/store.go:69                                                           |
| │ │           └─github.com/pingcap/tidb/store/mockstore.MockDriver.Open                                           | 42.43%      | 100%        |          1 |     8 | github.com/pingcap/tidb@/store/mockstore/tikv.go:47                                                  |
| │ │             └─github.com/pingcap/tidb/store/mockstore.NewMockTikvStore                                        | 42.43%      | 100%        |          1 |     9 | github.com/pingcap/tidb@/store/mockstore/tikv.go:106                                                 |
| │ │               └─github.com/pingcap/tidb/store/mockstore/mocktikv.NewTiKVAndPDClient                           | 42.43%      | 100%        |          1 |    10 | github.com/pingcap/tidb@/store/mockstore/mocktikv/mock.go:30                                         |
| │ │                 └─github.com/pingcap/tidb/store/mockstore/mocktikv.NewMVCCLevelDB                             | 42.43%      | 100%        |          1 |    11 | github.com/pingcap/tidb@/store/mockstore/mocktikv/mvcc_leveldb.go:124                                |
| │ │                   └─github.com/pingcap/goleveldb/leveldb.OpenFile                                             | 42.43%      | 100%        |          1 |    12 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/db.go:216                    |
| │ │                     └─github.com/pingcap/goleveldb/leveldb.Open                                               | 42.43%      | 100%        |          1 |    13 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/db.go:194                    |
| │ │                       └─github.com/pingcap/goleveldb/leveldb.openDB                                           | 42.43%      | 100%        |          1 |    14 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/db.go:122                    |
| │ │                         ├─github.com/pingcap/goleveldb/leveldb.(*DB).recoverJournal                           | 4.88%       | 11.50%      |          1 |    15 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/db.go:617                    |
| │ │                         │ └─github.com/pingcap/goleveldb/leveldb.(*session).commit                            | 4.88%       | 100%        |          1 |    16 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/session.go:199               |
| │ │                         │   └─github.com/pingcap/goleveldb/leveldb.(*session).newManifest                     | 4.88%       | 100%        |          1 |    17 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/session_util.go:198          |
| │ │                         │     └─github.com/pingcap/goleveldb/leveldb/journal.NewWriter                        | 4.88%       | 100%        |          1 |    18 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/journal/journal.go:370       |
| │ │                         └─github.com/pingcap/goleveldb/leveldb.(*DB).recoverJournal                           | 37.55%      | 88.50%      |          1 |    15 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/db.go:610                    |
| │ │                           └─github.com/pingcap/goleveldb/leveldb.(*DB).newMem                                 | 37.55%      | 100%        |          1 |    16 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/db_state.go:147              |
| │ │                             └─github.com/pingcap/goleveldb/leveldb.(*DB).mpoolGet                             | 37.55%      | 100%        |          1 |    17 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/db_state.go:90               |
| │ │                               └─github.com/pingcap/goleveldb/leveldb/memdb.New                                | 37.55%      | 100%        |          1 |    18 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/memdb/memdb.go:519           |
| │ └─main.main                                                                                                     | 4.73%       | 7.09%       |          1 |     2 | github.com/pingcap/tidb@/tidb-server/main.go:177                                                     |
| │   └─main.createServer                                                                                           | 4.73%       | 100%        |          1 |     3 | github.com/pingcap/tidb@/tidb-server/main.go:555                                                     |
| │     └─github.com/pingcap/tidb/server.NewServer                                                                  | 4.73%       | 100%        |          1 |     4 | github.com/pingcap/tidb@/server/server.go:200                                                        |
| │       └─github.com/pingcap/tidb/server.NewTokenLimiter                                                          | 4.73%       | 100%        |          1 |     5 | github.com/pingcap/tidb@/server/tokenlimiter.go:38                                                   |
| ├─runtime.main                                                                                                    | 23.90%      | 23.90%      |          2 |     1 | runtime/proc.go:190                                                                                  |
| │ └─runtime.doInit                                                                                                | 23.90%      | 100%        |          2 |     2 | runtime/proc.go:5217                                                                                 |
| │   └─runtime.doInit                                                                                              | 23.90%      | 100%        |          2 |     3 | runtime/proc.go:5217                                                                                 |
| │     ├─runtime.doInit                                                                                            | 19.20%      | 80.36%      |          2 |     4 | runtime/proc.go:5217                                                                                 |
| │     │ └─runtime.doInit                                                                                          | 19.20%      | 100%        |          2 |     5 | runtime/proc.go:5217                                                                                 |
| │     │   └─runtime.doInit                                                                                        | 19.20%      | 100%        |          2 |     6 | runtime/proc.go:5222                                                                                 |
| │     │     ├─github.com/pingcap/parser.init.0                                                                    | 4.70%       | 24.49%      |          2 |     7 | github.com/pingcap/parser@v0.0.0-20191025082927-f8adf1670b97/misc.go:114                             |
| │     │     │ └─github.com/pingcap/parser.initTokenString                                                         | 4.70%       | 100%        |          2 |     8 | github.com/pingcap/parser@v0.0.0-20191025082927-f8adf1670b97/misc.go:61                              |
| │     │     ├─github.com/pingcap/parser.init                                                                      | 4.88%       | 25.40%      |          2 |     7 | github.com/pingcap/parser@v0.0.0-20191025082927-f8adf1670b97/parser.go:691                           |
| │     │     ├─github.com/pingcap/parser.init                                                                      | 4.82%       | 25.11%      |          2 |     7 | github.com/pingcap/parser@v0.0.0-20191025082927-f8adf1670b97/parser.go:136                           |
| │     │     └─github.com/pingcap/tipb/go-tipb.init                                                                | 4.80%       | 25.01%      |          2 |     7 | github.com/pingcap/tipb@v0.0.0-20191015023537-709b39e7f8bb/go-tipb/expression.pb.go:1166             |
| │     └─runtime.doInit                                                                                            | 4.69%       | 19.64%      |          2 |     4 | runtime/proc.go:5222                                                                                 |
| │       └─github.com/pingcap/tidb/infoschema.init.0                                                               | 4.69%       | 100%        |          2 |     5 | github.com/pingcap/tidb@/infoschema/infoschema.go:375                                                |
| │         └─github.com/pingcap/tidb/infoschema.initInfoSchemaDB                                                   | 4.69%       | 100%        |          2 |     6 | github.com/pingcap/tidb@/infoschema/infoschema.go:386                                                |
| │           └─github.com/pingcap/tidb/infoschema.buildTableMeta                                                   | 4.69%       | 100%        |          2 |     7 | github.com/pingcap/tidb@/infoschema/tables.go:124                                                    |
| │             └─github.com/pingcap/tidb/infoschema.buildColumnInfo                                                | 4.69%       | 100%        |          2 |     8 | github.com/pingcap/tidb@/infoschema/tables.go:117                                                    |
| ├─github.com/pingcap/tidb/server.(*Server).startHTTPServer                                                        | 4.75%       | 4.75%       |          3 |     1 | github.com/pingcap/tidb@/server/http_status.go:73                                                    |
| │ └─github.com/prometheus/client_golang/prometheus.Handler                                                        | 4.75%       | 100%        |          3 |     2 | github.com/prometheus/client_golang@v0.9.0/prometheus/http.go:66                                     |
| │   └─github.com/prometheus/client_golang/prometheus.InstrumentHandler                                            | 4.75%       | 100%        |          3 |     3 | github.com/prometheus/client_golang@v0.9.0/prometheus/http.go:162                                    |
| │     └─github.com/prometheus/client_golang/prometheus.InstrumentHandlerFunc                                      | 4.75%       | 100%        |          3 |     4 | github.com/prometheus/client_golang@v0.9.0/prometheus/http.go:172                                    |
| │       └─github.com/prometheus/client_golang/prometheus.InstrumentHandlerFuncWithOpts                            | 4.75%       | 100%        |          3 |     5 | github.com/prometheus/client_golang@v0.9.0/prometheus/http.go:242                                    |
| │         └─github.com/prometheus/client_golang/prometheus.NewSummary                                             | 4.75%       | 100%        |          3 |     6 | github.com/prometheus/client_golang@v0.9.0/prometheus/summary.go:171                                 |
| │           └─github.com/prometheus/client_golang/prometheus.newSummary                                           | 4.75%       | 100%        |          3 |     7 | github.com/prometheus/client_golang@v0.9.0/prometheus/summary.go:233                                 |
| │             └─github.com/prometheus/client_golang/prometheus.(*summary).newStream                               | 4.75%       | 100%        |          3 |     8 | github.com/prometheus/client_golang@v0.9.0/prometheus/summary.go:330                                 |
| │               └─github.com/beorn7/perks/quantile.NewTargeted                                                    | 4.75%       | 100%        |          3 |     9 | github.com/beorn7/perks@v0.0.0-20180321164747-3a771d992973/quantile/stream.go:101                    |
| │                 └─github.com/beorn7/perks/quantile.newStream                                                    | 4.75%       | 100%        |          3 |    10 | github.com/beorn7/perks@v0.0.0-20180321164747-3a771d992973/quantile/stream.go:133                    |
| └─github.com/pingcap/tidb/store/tikv.(*copIteratorWorker).run                                                     | 4.69%       | 4.69%       |          4 |     1 | github.com/pingcap/tidb@/store/tikv/coprocessor.go:452                                               |
|   └─github.com/pingcap/tidb/store/tikv.(*copIteratorWorker).handleTask                                            | 4.69%       | 100%        |          4 |     2 | github.com/pingcap/tidb@/store/tikv/coprocessor.go:624                                               |
|     └─github.com/pingcap/tidb/store/tikv.(*copIteratorWorker).handleTaskOnce                                      | 4.69%       | 100%        |          4 |     3 | github.com/pingcap/tidb@/store/tikv/coprocessor.go:660                                               |
|       └─github.com/pingcap/tidb/store/tikv.(*RegionRequestSender).SendReqCtx                                      | 4.69%       | 100%        |          4 |     4 | github.com/pingcap/tidb@/store/tikv/region_request.go:140                                            |
|         └─github.com/pingcap/tidb/store/tikv.(*RegionRequestSender).sendReqToRegion                               | 4.69%       | 100%        |          4 |     5 | github.com/pingcap/tidb@/store/tikv/region_request.go:170                                            |
|           └─github.com/pingcap/tidb/store/mockstore/mocktikv.(*RPCClient).SendRequest                             | 4.69%       | 100%        |          4 |     6 | github.com/pingcap/tidb@/store/mockstore/mocktikv/rpc.go:934                                         |
|             └─github.com/pingcap/tidb/store/mockstore/mocktikv.(*rpcHandler).handleCopDAGRequest                  | 4.69%       | 100%        |          4 |     7 | github.com/pingcap/tidb@/store/mockstore/mocktikv/cop_handler_dag.go:70                              |
|               └─github.com/pingcap/tidb/store/mockstore/mocktikv.(*indexScanExec).Next                            | 4.69%       | 100%        |          4 |     8 | github.com/pingcap/tidb@/store/mockstore/mocktikv/executor.go:341                                    |
|                 └─github.com/pingcap/tidb/store/mockstore/mocktikv.(*indexScanExec).getRowFromRange               | 4.69%       | 100%        |          4 |     9 | github.com/pingcap/tidb@/store/mockstore/mocktikv/executor.go:385                                    |
|                   └─github.com/pingcap/tidb/store/mockstore/mocktikv.(*MVCCLevelDB).Scan                          | 4.69%       | 100%        |          4 |    10 | github.com/pingcap/tidb@/store/mockstore/mocktikv/mvcc_leveldb.go:352                                |
|                     └─github.com/pingcap/tidb/store/mockstore/mocktikv.getValue                                   | 4.69%       | 100%        |          4 |    11 | github.com/pingcap/tidb@/store/mockstore/mocktikv/mvcc_leveldb.go:294                                |
|                       └─github.com/pingcap/tidb/store/mockstore/mocktikv.(*valueDecoder).Decode                   | 4.69%       | 100%        |          4 |    12 | github.com/pingcap/tidb@/store/mockstore/mocktikv/mvcc_leveldb.go:237                                |
|                         └─github.com/pingcap/tidb/store/mockstore/mocktikv.(*Iterator).Next                       | 4.69%       | 100%        |          4 |    13 | github.com/pingcap/tidb@/store/mockstore/mocktikv/mvcc_leveldb.go:138                                |
|                           └─github.com/pingcap/goleveldb/leveldb.(*dbIter).Next                                   | 4.69%       | 100%        |          4 |    14 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/db_iter.go:240               |
|                             └─github.com/pingcap/goleveldb/leveldb/iterator.(*mergedIterator).Next                | 4.69%       | 100%        |          4 |    15 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/iterator/merged_iter.go:169  |
|                               └─github.com/pingcap/goleveldb/leveldb/iterator.(*indexedIterator).Next             | 4.69%       | 100%        |          4 |    16 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/iterator/indexed_iter.go:149 |
|                                 └─github.com/pingcap/goleveldb/leveldb/iterator.(*indexedIterator).Next           | 4.69%       | 100%        |          4 |    17 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/iterator/indexed_iter.go:160 |
|                                   └─github.com/pingcap/goleveldb/leveldb/iterator.(*indexedIterator).setData      | 4.69%       | 100%        |          4 |    18 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/iterator/indexed_iter.go:39  |
|                                     └─github.com/pingcap/goleveldb/leveldb/table.(*indexIter).Get                 | 4.69%       | 100%        |          4 |    19 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/table/reader.go:507          |
|                                       └─github.com/pingcap/goleveldb/leveldb/table.(*Reader).getDataIterErr       | 4.69%       | 100%        |          4 |    20 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/table/reader.go:780          |
|                                         └─github.com/pingcap/goleveldb/leveldb/table.(*Reader).getDataIter        | 4.69%       | 100%        |          4 |    21 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/table/reader.go:769          |
|                                           └─github.com/pingcap/goleveldb/leveldb/table.(*Reader).newBlockIter     | 4.69%       | 100%        |          4 |    22 | github.com/pingcap/goleveldb@v0.0.0-20171020122428-b9ff6c35079e/leveldb/table/reader.go:736          |
+-------------------------------------------------------------------------------------------------------------------+-------------+-------------+------------+-------+------------------------------------------------------------------------------------------------------+
97 rows in set (0.09 sec)

And we can filter some leavies easily.

mysql> select * from performance_schema.tidb_profile_memory where depth < 5;
+------------------------------------------------------------------------------------+-------------+-------------+------------+-------+-------------------------------------------------------------------+
| FUNCTION                                                                           | PERCENT_ABS | PERCENT_REL | ROOT_CHILD | DEPTH | FILE                                                              |
+------------------------------------------------------------------------------------+-------------+-------------+------------+-------+-------------------------------------------------------------------+
| root                                                                               | 100%        | 100%        |          0 |     0 | root                                                              |
| ├─runtime.main                                                                     | 63.67%      | 63.67%      |          1 |     1 | runtime/proc.go:203                                               |
| │ ├─main.main                                                                      | 4.52%       | 7.09%       |          1 |     2 | github.com/pingcap/tidb@/tidb-server/main.go:177                  |
| │ │ └─main.createServer                                                            | 4.52%       | 100%        |          1 |     3 | github.com/pingcap/tidb@/tidb-server/main.go:555                  |
| │ │   └─github.com/pingcap/tidb/server.NewServer                                   | 4.52%       | 100%        |          1 |     4 | github.com/pingcap/tidb@/server/server.go:200                     |
| │ └─main.main                                                                      | 59.16%      | 92.91%      |          1 |     2 | github.com/pingcap/tidb@/tidb-server/main.go:176                  |
| │   ├─main.createStoreAndDomain                                                    | 40.53%      | 68.50%      |          1 |     3 | github.com/pingcap/tidb@/tidb-server/main.go:235                  |
| │   │ └─github.com/pingcap/tidb/store.New                                          | 40.53%      | 100%        |          1 |     4 | github.com/pingcap/tidb@/store/store.go:51                        |
| │   └─main.createStoreAndDomain                                                    | 18.63%      | 31.50%      |          1 |     3 | github.com/pingcap/tidb@/tidb-server/main.go:238                  |
| │     └─github.com/pingcap/tidb/session.BootstrapSession                           | 18.63%      | 100%        |          1 |     4 | github.com/pingcap/tidb@/session/session.go:1579                  |
| ├─runtime.main                                                                     | 22.83%      | 22.83%      |          2 |     1 | runtime/proc.go:190                                               |
| │ └─runtime.doInit                                                                 | 22.83%      | 100%        |          2 |     2 | runtime/proc.go:5217                                              |
| │   └─runtime.doInit                                                               | 22.83%      | 100%        |          2 |     3 | runtime/proc.go:5217                                              |
| │     ├─runtime.doInit                                                             | 4.48%       | 19.64%      |          2 |     4 | runtime/proc.go:5222                                              |
| │     └─runtime.doInit                                                             | 18.34%      | 80.36%      |          2 |     4 | runtime/proc.go:5217                                              |
| ├─github.com/pingcap/tidb/store/tikv.(*copIteratorWorker).run                      | 8.96%       | 8.96%       |          3 |     1 | github.com/pingcap/tidb@/store/tikv/coprocessor.go:452            |
| │ └─github.com/pingcap/tidb/store/tikv.(*copIteratorWorker).handleTask             | 8.96%       | 100%        |          3 |     2 | github.com/pingcap/tidb@/store/tikv/coprocessor.go:624            |
| │   └─github.com/pingcap/tidb/store/tikv.(*copIteratorWorker).handleTaskOnce       | 8.96%       | 100%        |          3 |     3 | github.com/pingcap/tidb@/store/tikv/coprocessor.go:660            |
| │     └─github.com/pingcap/tidb/store/tikv.(*RegionRequestSender).SendReqCtx       | 8.96%       | 100%        |          3 |     4 | github.com/pingcap/tidb@/store/tikv/region_request.go:140         |
| └─github.com/pingcap/tidb/server.(*Server).startHTTPServer                         | 4.53%       | 4.53%       |          4 |     1 | github.com/pingcap/tidb@/server/http_status.go:73                 |
|   └─github.com/prometheus/client_golang/prometheus.Handler                         | 4.53%       | 100%        |          4 |     2 | github.com/prometheus/client_golang@v0.9.0/prometheus/http.go:66  |
|     └─github.com/prometheus/client_golang/prometheus.InstrumentHandler             | 4.53%       | 100%        |          4 |     3 | github.com/prometheus/client_golang@v0.9.0/prometheus/http.go:162 |
|       └─github.com/prometheus/client_golang/prometheus.InstrumentHandlerFunc       | 4.53%       | 100%        |          4 |     4 | github.com/prometheus/client_golang@v0.9.0/prometheus/http.go:172 |
+------------------------------------------------------------------------------------+-------------+-------------+------------+-------+-------------------------------------------------------------------+

Check List

Tests

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

Code changes

  • Has exported function/method change

Related changes

  • Need to update the documentation

Release note

  • [feature] Support query cpu/memory/mutex/block/allocs/goroutines flamegraph by SQL.
lonng added 2 commits Oct 13, 2019
cpu/memory/mutex/block/allocs/goroutines

Signed-off-by: Lonng <heng@lonng.org>
infoschema/perfschema/const.go Outdated Show resolved Hide resolved
infoschema/perfschema/const.go Outdated Show resolved Hide resolved
infoschema/perfschema/const.go Outdated Show resolved Hide resolved
infoschema/perfschema/tables.go Show resolved Hide resolved
@siddontang

This comment has been minimized.

Copy link
Member

siddontang commented Oct 29, 2019

can we change the line style?

It is verbose to show the prefix github.com/pingcap/tidb/ at first, e.g

image

As we can see, it is hard to find the actual function, especially when the depth is high.

maybe we can change the output format like tikv.(*copIteratorWorker).run@github.com/pingcap/tidb/store, so we can learn the backtrace more easily.

@lonng

This comment has been minimized.

Copy link
Member Author

lonng commented Oct 29, 2019

can we change the line style?

It is verbose to show the prefix github.com/pingcap/tidb/ at first, e.g

image

As we can see, it is hard to find the actual function, especially when the depth is high.

maybe we can change the output format like tikv.(*copIteratorWorker).run@github.com/pingcap/tidb/store, so we can learn the backtrace more easily.

Good idea.

Signed-off-by: Lonng <heng@lonng.org>
@codecov

This comment has been minimized.

Copy link

codecov bot commented Oct 29, 2019

Codecov Report

Merging #12986 into master will increase coverage by 0.6273%.
The diff coverage is n/a.

@@               Coverage Diff                @@
##             master     #12986        +/-   ##
================================================
+ Coverage   80.0579%   80.6852%   +0.6273%     
================================================
  Files           468        468                
  Lines        109367     113152      +3785     
================================================
+ Hits          87557      91297      +3740     
+ Misses        15118      15080        -38     
- Partials       6692       6775        +83
lonng added 5 commits Oct 29, 2019
Signed-off-by: Lonng <heng@lonng.org>
@lonng

This comment has been minimized.

Copy link
Member Author

lonng commented Oct 29, 2019

/run-all-tests

@lonng

This comment has been minimized.

Copy link
Member Author

lonng commented Oct 29, 2019

@siddontang I have tried to trim the prefix but found it's harder to read the result. So I think it's better to keep the current form before we found a better way.

go.mod Show resolved Hide resolved
@djshow832

This comment has been minimized.

Copy link
Contributor

djshow832 commented Oct 29, 2019

LGTM

Copy link
Member

crazycs520 left a comment

LGTM

@crazycs520 crazycs520 added status/LGT2 and removed status/LGT1 labels Oct 29, 2019
crazycs520 and others added 2 commits Oct 29, 2019
@sre-bot

This comment has been minimized.

Copy link

sre-bot commented Oct 29, 2019

/run-all-tests

@lonng lonng merged commit 953c0a6 into pingcap:master Oct 29, 2019
13 checks passed
13 checks passed
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/build_check_race Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/check_dev_2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/common-test job succeeded
Details
idc-jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/mybatis-test job succeeded
Details
idc-jenkins-ci-tidb/sqllogic-test-1 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/sqllogic-test-2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
@lonng lonng deleted the lonng:perf-tables branch Oct 29, 2019
@sre-bot

This comment has been minimized.

Copy link

sre-bot commented Oct 29, 2019

cherry pick to release-3.0 failed

@sre-bot

This comment has been minimized.

Copy link

sre-bot commented Oct 29, 2019

cherry pick to release-3.1 failed

lonng added a commit to lonng/tidb that referenced this pull request Oct 30, 2019
…amegraph by SQL (pingcap#12986)

Signed-off-by: Lonng <heng@lonng.org>
lonng added a commit to lonng/tidb that referenced this pull request Oct 30, 2019
…amegraph by SQL (pingcap#12986)

Signed-off-by: Lonng <heng@lonng.org>
sre-bot added a commit that referenced this pull request Oct 30, 2019
ngaut added a commit that referenced this pull request Oct 30, 2019
@lonng lonng mentioned this pull request Nov 19, 2019
53 of 56 tasks complete
@dcalvin dcalvin changed the title perfschema: support query cpu/memory/mutex/block/allocs/goroutines flamegraph by SQL perfschema: support performance flame-graph by SQL Nov 19, 2019
XiaTianliang added a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
…amegraph by SQL (pingcap#12986)

Signed-off-by: Lonng <heng@lonng.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.