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

gh-103295: expose API for writing perf map files #103546

Merged
merged 60 commits into from
May 21, 2023
Merged
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f76d2c5
Update osmodule.h
gsallam Apr 14, 2023
de6b63e
Update posixmodule.c
gsallam Apr 14, 2023
4f55b2d
Update pycore_ceval_state.h
gsallam Apr 14, 2023
03fccfb
Update perf_trampoline.c
gsallam Apr 14, 2023
78d543a
Update pylifecycle.c
gsallam Apr 14, 2023
e8c321d
Update pycore_ceval.h
gsallam Apr 14, 2023
3a97933
Update _testinternalcapi.c
gsallam Apr 14, 2023
94441c4
Create test_perfmaps.py
gsallam Apr 14, 2023
a221fd8
Update posixmodule.c
gsallam Apr 14, 2023
392e842
Update osmodule.h
gsallam Apr 14, 2023
4223241
Update osmodule.h
gsallam Apr 14, 2023
804153a
Update osmodule.h
gsallam Apr 14, 2023
ce54c6c
Update posixmodule.c
gsallam Apr 14, 2023
6c3f233
📜🤖 Added by blurb_it.
blurb-it[bot] Apr 14, 2023
71db361
Update osmodule.h
gsallam Apr 15, 2023
020c872
Update test_perfmaps.py
gsallam Apr 15, 2023
e33b45d
Update ignored.tsv
gsallam Apr 15, 2023
04e9716
Fix trampoline APIs on windows, return int instead of void* from the …
czardoz Apr 18, 2023
4b8cd26
fix restructuredtext literals
czardoz Apr 19, 2023
ccc2d5b
add perfmaps docs under utilities
czardoz Apr 19, 2023
71a7578
make "state" a non-required part of trampoline
czardoz Apr 19, 2023
0ede039
make the API no-op on windows, instead of raising errors
czardoz Apr 20, 2023
7356a9b
use PyUnstable as a prefix
gsallam May 8, 2023
b504e9a
move the implementation of the perf-map api to the sys module
gsallam May 8, 2023
99dab1a
Remove the perf-map API from the posixmodule.c
gsallam May 8, 2023
6b95cbc
Update perfmaps.rst to reflect the PyUnstable prefix
gsallam May 8, 2023
d0ef0a1
Update perf_trampoline.c to use PyUnstable_WritePerfMapEntry
gsallam May 8, 2023
c5e766b
Update pylifecycle.c to use PyUnstable_PerfMapState_Fini
gsallam May 8, 2023
b0641a7
expose PyUnstable_PerfMapState_Fini
gsallam May 8, 2023
c392b24
use assertIn instead of assertEqual and tear down the perf_map_state …
gsallam May 8, 2023
262a38b
use malloc instead of fixed buffer size
gsallam May 8, 2023
a52a25a
Fix perf map entry to have the START and SIZE as hex numbers without 0x
gsallam May 8, 2023
0932e30
Add (uintptr_t) casting for the code_addr
gsallam May 8, 2023
5aeb74c
update the perf map entry example to be hex without 0x
gsallam May 8, 2023
b0682e0
Update the doc with the PyUnstable prefix
gsallam May 8, 2023
db00a03
Merge remote-tracking branch 'upstream/main'
czardoz May 8, 2023
e581026
change function name to the new one
czardoz May 8, 2023
e185092
fix tests_perfmaps
gsallam May 9, 2023
c97137b
Update ignored.tsv
gsallam May 9, 2023
344782b
remove extra new line
gsallam May 9, 2023
1ff695a
remove extra trailing white space
gsallam May 9, 2023
2f13a4e
check perf_map_entry for NULL.
gpshead May 9, 2023
faa85f5
Merge remote-tracking branch 'upstream/main'
czardoz May 9, 2023
50d27e1
update docs
czardoz May 9, 2023
717c4e4
remove rst extension from inline doc links
czardoz May 9, 2023
428dfc3
fix the free_state function signature
czardoz May 18, 2023
ca2c0ff
Merge remote-tracking branch 'upstream/main'
czardoz May 18, 2023
e386ef8
trim extra whitespace
czardoz May 18, 2023
d245fbf
Return error codes instead of setting exceptions in PyUnstable_PerfMa…
gsallam May 20, 2023
2027de6
Add a note that holding the GIL is not required for these APIs
gsallam May 20, 2023
0383b80
Remove the init_state call since it is always NULL for the perf backend
gsallam May 20, 2023
59f3c15
trim extra whitespaces
gsallam May 20, 2023
8bc6150
simplify link to perf map docs from perf profiling
carljm May 20, 2023
c7a49b4
document return values, other doc tweaks
carljm May 20, 2023
125513a
move headers to sysmodule.h
carljm May 20, 2023
10630e8
pass through init return value from write-entry
carljm May 20, 2023
386dd42
apparently :c:data:`errno` doesn't exist
carljm May 20, 2023
6585f32
use PyMem_Raw* instead of malloc/free
carljm May 20, 2023
ea5965a
Merge branch 'main' into gsallam/main
carljm May 20, 2023
e6be2a7
fix PyMem_Free to PyMem_RawFree
carljm May 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
document return values, other doc tweaks
  • Loading branch information
carljm committed May 20, 2023
commit c7a49b4da6b4923b8306bcd7c79335f032cbe761
24 changes: 14 additions & 10 deletions Doc/c-api/perfmaps.rst
carljm marked this conversation as resolved.
Show resolved Hide resolved
carljm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -23,9 +23,12 @@ Note that holding the Global Interpreter Lock (GIL) is not required for these AP
Open the ``/tmp/perf-$pid.map`` file, unless it's already opened, and create
a lock to ensure thread-safe writes to the file (provided the writes are
done through :c:func:`PyUnstable_WritePerfMapEntry`). Normally, there's no need
to call this explicitly, and it is safe to directly use :c:func:`PyUnstable_WritePerfMapEntry`
in your code. If the state isn't already initialized, it will be created on
the first call.
to call this explicitly; just use :c:func:`PyUnstable_WritePerfMapEntry`
and it will initialize the state on first call.

Returns ``0`` on success, ``-1`` on failure to create/open the perf map file,
or ``-2`` on failure to create a lock. Check :c:data:`errno` for more
information about the cause of a failure.

.. c:function:: int PyUnstable_WritePerfMapEntry(const void *code_addr, unsigned int code_size, const char *entry_name)

@@ -35,12 +38,13 @@ Note that holding the Global Interpreter Lock (GIL) is not required for these AP
# address size name
7f3529fcf759 b py::bar:/run/t.py

Extensions are encouraged to directly call this API when needed, instead of
separately initializing the state by calling :c:func:`PyUnstable_PerfMapState_Init`.
Will call :c:func:`PyUnstable_PerfMapState_Init` before writing the entry, if
the perf map file is not already opened. Returns ``0`` on success, or the
same error codes as :c:func:`PyUnstable_PerfMapState_Init` on failure.

.. c:function:: int PyUnstable_PerfMapState_Fini(void)
.. c:function:: void PyUnstable_PerfMapState_Fini(void)

Close the perf map file, which was opened in ``PyUnstable_PerfMapState_Init``. This
API is called by the runtime itself, during interpreter shut-down. In general,
there shouldn't be a reason to explicitly call this, except to handle specific
scenarios such as forking.
Close the perf map file opened by :c:func:`PyUnstable_PerfMapState_Init`.
This is called by the runtime itself during interpreter shut-down. In
general, there shouldn't be a reason to explicitly call this, except to
handle specific scenarios such as forking.