This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unify handling of stats in the CPython VM
Type: Stage: patch review
Components: Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, brandtbucher, christian.heimes
Priority: normal Keywords: patch

Created on 2021-12-14 16:17 by Mark.Shannon, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 30116 merged Mark.Shannon, 2021-12-15 10:36
PR 30139 merged Mark.Shannon, 2021-12-16 11:29
PR 30145 merged Mark.Shannon, 2021-12-16 15:21
PR 30169 merged Mark.Shannon, 2021-12-17 13:49
PR 30989 merged Mark.Shannon, 2022-01-28 14:28
PR 31051 merged Mark.Shannon, 2022-02-01 12:26
PR 31060 merged Mark.Shannon, 2022-02-01 16:34
PR 31079 merged Mark.Shannon, 2022-02-02 14:55
PR 31104 merged Mark.Shannon, 2022-02-03 17:04
PR 31105 merged Mark.Shannon, 2022-02-03 18:06
PR 31108 merged Mark.Shannon, 2022-02-03 19:08
PR 31197 merged Mark.Shannon, 2022-02-07 14:40
PR 31211 merged Mark.Shannon, 2022-02-08 09:52
PR 31228 merged Mark.Shannon, 2022-02-09 11:48
PR 31234 merged Mark.Shannon, 2022-02-09 18:26
PR 31250 merged Mark.Shannon, 2022-02-10 11:12
PR 31251 merged Mark.Shannon, 2022-02-10 11:45
PR 31254 merged Mark.Shannon, 2022-02-10 12:56
PR 31259 merged Mark.Shannon, 2022-02-10 13:25
PR 31289 merged brandtbucher, 2022-02-11 22:01
PR 31324 merged Mark.Shannon, 2022-02-14 12:39
Messages (14)
msg408543 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-12-14 16:17
By "stats" I mean the internal numbers gathered by the VM for performance and debugging. This has nothing to do with any statistics module.

Currently various parts of the VM gather stats: the GC, dicts, the bytecode interpreter, type lookup cache, etc.

These stats have various compile time flags to turn them on and off. They have differing ways to display the stats, and no unified way to gather stats across different runs.

For the specialization stats we dump stats, which we can parse to collate stats across runs.

We should:
1. Add a --with-pystats config flag (like with-pydebug) to turn on stat gathering at build time.
2. Convert the other stats to the format used by the specialization stats, so all stats can be parsed and collated.
msg408613 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-12-15 15:32
New changeset 342b93f9f28746abb7b221a61d5a9b26ccbb395a by Mark Shannon in branch 'main':
bpo-46072: Add --with-pystats configure option to simplify gathering of VM stats (GH-30116)
https://github.com/python/cpython/commit/342b93f9f28746abb7b221a61d5a9b26ccbb395a
msg408618 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-12-15 17:14
Could you please add the new option to Doc/using/configure.rst ?
msg408702 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-12-16 13:41
New changeset 4506bbede1644e985991884964b43afa7ee6f609 by Mark Shannon in branch 'main':
bpo-46072: Document --enable-stats option. (GH-30139)
https://github.com/python/cpython/commit/4506bbede1644e985991884964b43afa7ee6f609
msg408704 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-12-16 14:25
I just noticed that you are using hard-coded paths with /tmp for the pystats directory. That's problematic and opens the possibility of a symlink race attack.

Could please add exclusive create to _Py_PrintSpecializationStats()? The will prevent symlink attacks. fopen() mode "x" is not generally available in all libcs. You have to combine open() and fdopen():


int flags = O_WRONLY | O_CREAT | O_EXCL;
#ifdef O_NOFOLLOW
flags |= O_NOFOLLOW;
#endif
#ifdef O_CLOEXEC
flags |= O_CLOEXEC;
#endif

int fd = open(path, flags);
if (fd >= 0) {
    FILE *fout = fdopen(fd, "w");
}
msg408708 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-12-16 14:47
The --enable-stats option is for CPython development and shouldn't be turned on for a release version, so I'm not really concerned about people attacking their own machines.
msg408787 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-12-17 14:48
New changeset efd6236d36b292c2c43540132c87cf8425e8d627 by Mark Shannon in branch 'main':
bpo-46072:  Add top level stats struct (GH-30169)
https://github.com/python/cpython/commit/efd6236d36b292c2c43540132c87cf8425e8d627
msg412002 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-01-28 15:20
New changeset 90ab138bbdc63763ad825ed6d4821367c09c4015 by Mark Shannon in branch 'main':
bpo-46072: Add simple stats for Python calls. (GH-30989)
https://github.com/python/cpython/commit/90ab138bbdc63763ad825ed6d4821367c09c4015
msg412271 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-01 15:05
New changeset 48be46ec1f3f8010570165daa1da4bf9961f3a83 by Mark Shannon in branch 'main':
bpo-46072: Add some object layout and allocation stats (GH-31051)
https://github.com/python/cpython/commit/48be46ec1f3f8010570165daa1da4bf9961f3a83
msg412350 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-02 11:02
New changeset 187930f74c44e460ba09c60ba5d9bb4fac543d8f by Mark Shannon in branch 'main':
bpo-46072: Add some frame stats. (GH-31060)
https://github.com/python/cpython/commit/187930f74c44e460ba09c60ba5d9bb4fac543d8f
msg412750 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-07 14:31
New changeset 062460e8fd54e53c9a1a6f175ef49c9d730851b8 by Mark Shannon in branch 'main':
bpo-46072: Improve LOAD_METHOD stats (GH-31104)
https://github.com/python/cpython/commit/062460e8fd54e53c9a1a6f175ef49c9d730851b8
msg412769 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-07 16:51
New changeset 9c979d7afd839abbb080028bdfeb73727e5cf633 by Mark Shannon in branch 'main':
bpo-46072: Merge dxpairs into py_stats. (GH-31197)
https://github.com/python/cpython/commit/9c979d7afd839abbb080028bdfeb73727e5cf633
msg412901 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-09 12:30
New changeset f71a69aa9209cf67cc1060051b147d6afa379bba by Mark Shannon in branch 'main':
bpo-46072: Output stats as markdown with collapsible sections. (GH-31228)
https://github.com/python/cpython/commit/f71a69aa9209cf67cc1060051b147d6afa379bba
msg413341 - (view) Author: Brandt Bucher (brandtbucher) * (Python committer) Date: 2022-02-16 16:50
New changeset 580cd9ab2992b7df6f4815020b5841e14a5a6977 by Brandt Bucher in branch 'main':
bpo-46072: Add detailed failure stats for BINARY_OP (GH-31289)
https://github.com/python/cpython/commit/580cd9ab2992b7df6f4815020b5841e14a5a6977
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90230
2022-02-16 16:50:02brandtbuchersetmessages: + msg413341
2022-02-14 12:39:07Mark.Shannonsetpull_requests: + pull_request29481
2022-02-11 22:01:57brandtbuchersetnosy: + brandtbucher
pull_requests: + pull_request29449
2022-02-10 13:25:08Mark.Shannonsetpull_requests: + pull_request29425
2022-02-10 12:56:12Mark.Shannonsetpull_requests: + pull_request29422
2022-02-10 11:45:45Mark.Shannonsetpull_requests: + pull_request29420
2022-02-10 11:12:19Mark.Shannonsetpull_requests: + pull_request29419
2022-02-09 18:26:00Mark.Shannonsetpull_requests: + pull_request29404
2022-02-09 12:30:39Mark.Shannonsetmessages: + msg412901
2022-02-09 11:48:38Mark.Shannonsetpull_requests: + pull_request29398
2022-02-08 09:52:26Mark.Shannonsetpull_requests: + pull_request29381
2022-02-07 16:51:53Mark.Shannonsetmessages: + msg412769
2022-02-07 14:40:19Mark.Shannonsetpull_requests: + pull_request29368
2022-02-07 14:31:00Mark.Shannonsetmessages: + msg412750
2022-02-03 19:08:02Mark.Shannonsetpull_requests: + pull_request29291
2022-02-03 18:06:28Mark.Shannonsetpull_requests: + pull_request29288
2022-02-03 17:04:37Mark.Shannonsetpull_requests: + pull_request29287
2022-02-02 14:55:08Mark.Shannonsetpull_requests: + pull_request29263
2022-02-02 11:02:00Mark.Shannonsetmessages: + msg412350
2022-02-01 16:34:24Mark.Shannonsetpull_requests: + pull_request29242
2022-02-01 15:05:39Mark.Shannonsetmessages: + msg412271
2022-02-01 12:26:23Mark.Shannonsetpull_requests: + pull_request29233
2022-01-28 15:20:56Mark.Shannonsetmessages: + msg412002
2022-01-28 14:28:07Mark.Shannonsetpull_requests: + pull_request29168
2021-12-17 14:48:11Mark.Shannonsetmessages: + msg408787
2021-12-17 13:49:46Mark.Shannonsetpull_requests: + pull_request28386
2021-12-16 15:21:49Mark.Shannonsetpull_requests: + pull_request28363
2021-12-16 14:47:13Mark.Shannonsetmessages: + msg408708
2021-12-16 14:25:02christian.heimessetmessages: + msg408704
2021-12-16 13:41:06Mark.Shannonsetmessages: + msg408702
2021-12-16 11:29:34Mark.Shannonsetpull_requests: + pull_request28357
2021-12-15 17:14:09christian.heimessetnosy: + christian.heimes
messages: + msg408618
2021-12-15 15:32:41Mark.Shannonsetmessages: + msg408613
2021-12-15 10:36:14Mark.Shannonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28338
2021-12-14 16:17:53Mark.Shannoncreate