•  


gh-103295: expose API for writing perf map files by gsallam · Pull Request #103546 · python/cpython · GitHub
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

Conversation

gsallam
Copy link
Contributor

@gsallam gsallam commented Apr 14, 2023

#96123 added support for CPython to write /tmp/perf-.map files, associating instruction address ranges with a human-readable frame name for the Linux perf profiler.

Two external Python JIT compilers, Cinder and Pyston , both also independently write to perf map files.

Since perf map files are one-per-process, multiple separate libraries trying to write perf map entries independently can lead to file corruption from simultaneous writes.

It's unlikely for both Cinder and Pyston JITs to be used in the same process, but it's quite reasonable to use one of these JITs along with CPython's native perf trampoline support.

This PR add a C-API to write to the perf map file. It also update the perf trampoline to use the new API to write to the perf map file.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented Apr 14, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry .

Please add it using the blurb_it web app or the blurb command-line tool.

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry .

Please add it using the blurb_it web app or the blurb command-line tool.

4 similar comments
@bedevere-bot
Copy link

Most changes to Python require a NEWS entry .

Please add it using the blurb_it web app or the blurb command-line tool.

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry .

Please add it using the blurb_it web app or the blurb command-line tool.

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry .

Please add it using the blurb_it web app or the blurb command-line tool.

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry .

Please add it using the blurb_it web app or the blurb command-line tool.

@gsallam gsallam marked this pull request as ready for review April 16, 2023 20:50
@arhadthedev arhadthedev added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Apr 19, 2023
@czardoz
Copy link
Contributor

Looks like the CI is having trouble installing dependencies, I will update this branch with rebase and try again in a bit

facebook-github-bot pushed a commit to facebookincubator/cinder that referenced this pull request May 19, 2023
Summary: Backport the perf-trampoline introduced in 
python/cpython#96123
.  The perf trampoline doesn't work properly with the JIT, so we have submitted a PR to have a C-API to unify writing to the perf-map files 
python/cpython#103546
.

Reviewed By: czardoz

Differential Revision: D45419843

fbshipit-source-id: 16bd13d7981e48c9eb7bc0e5eef1c1f4748965f6
facebook-github-bot pushed a commit to facebookincubator/cinder that referenced this pull request May 19, 2023
Summary:
With the perf trampoline writing to the perf-map files, we want to have a C-API to unify writing to the perf-map files to avoid file corruption from simultaneous writes. We are trying to upstream the API here 
python/cpython#103546
. More details about the motivation is in the PR.

In addition to introducing the C-API, we also change JIT to utilize the new C-API.

Reviewed By: czardoz

Differential Revision: D45421966

fbshipit-source-id: d270cc753a245f93cbfe3d723d0880595fef45f2
@carljm carljm added the ?? test-with-buildbots Test PR w/ buildbots; report in status section label May 20, 2023
@bedevere-bot
Copy link

?? New build scheduled with the buildbot fleet by @carljm for commit 10630e8 ??

If you want to schedule another build, you need to add the ?? test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the ?? test-with-buildbots Test PR w/ buildbots; report in status section label May 20, 2023
Python/perf_trampoline.c Outdated Show resolved Hide resolved
Python/perf_trampoline.c Outdated Show resolved Hide resolved
* main: (30 commits)
  
pythongh-103987
: fix several crashes in mmap module (
python#103990
)
  docs: fix wrong indentation causing rendering error in dis page (
python#104661
)
  
pythongh-94906
: Support multiple steps in math.nextafter (
python#103881
)
  
pythongh-104472
: Skip `test_subprocess.ProcessTestCase.test_empty_env` if ASAN is enabled (
python#104667
)
  
pythongh-103839
: Allow building Tkinter against Tcl 8.7 without external libtommath (
pythonGH-103842
)
  
pythongh-85984
: New additions and improvements to the tty library. (
python#101832
)
  
pythongh-104659
: Consolidate python examples in enum documentation (
python#104665
)
  
pythongh-92248
: Deprecate `type`, `choices`, `metavar` parameters of `argparse.BooleanOptionalAction` (
python#103678
)
  
pythongh-104645
: fix error handling in marshal tests (
python#104646
)
  
pythongh-104600
: Make type.__type_params__ writable (
python#104634
)
  
pythongh-104602
: Add additional test for listcomp with lambda (
python#104639
)
  
pythongh-104640
: Disallow walrus in comprehension within type scopes (
python#104641
)
  
pythongh-103921
: Rename "type" header in argparse docs (
python#104654
)
  Improve readability of `typing._ProtocolMeta.__instancecheck__` (
python#104649
)
  
pythongh-96522
: Fix deadlock in pty.spawn (
python#96639
)
  
pythonGH-102818
: Do not call `PyTraceBack_Here` in sys.settrace trampoline.  (
pythonGH-104579
)
  
pythonGH-103545
: Add macOS specific constants for ``os.setpriority`` to ``os`` (
python#104606
)
  
pythongh-104623
: Update macOS installer to SQLite 3.42.0 (
pythonGH-104624
)
  
pythongh-104619
: never leak comprehension locals to outer locals() (
python#104637
)
  
pythongh-104602
: ensure all cellvars are known up front (
python#104603
)
  ...
@carljm carljm added the ?? test-with-buildbots Test PR w/ buildbots; report in status section label May 20, 2023
@bedevere-bot
Copy link

?? New build scheduled with the buildbot fleet by @carljm for commit e6be2a7 ??

If you want to schedule another build, you need to add the ?? test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the ?? test-with-buildbots Test PR w/ buildbots; report in status section label May 20, 2023
@carljm
Copy link
Member

carljm commented May 20, 2023

Refleak buildbot failures are unrelated, they are all failing in test_mmap , which is a known issue on main: #104698 . Otherwise buildbots look happy.

I think this is ready for merge; @pablogsal I will plan to merge it tomorrow evening unless you have objections!

@pablogsal pablogsal merged commit be0c106 into python : main May 21, 2023
90 of 101 checks passed
@pablogsal
Copy link
Member

I think this is ready for merge; @pablogsal I will plan to merge it tomorrow evening unless you have objections!

I went ahead and land it myself after another review pass ??

Great job everyone!

facebook-github-bot pushed a commit to facebookincubator/cinder that referenced this pull request May 24, 2023
Summary:
Port the latest changes from the [perf-map C-API PR](
python/cpython#103546
). This includes using error codes instead of exceptions to avoid the need to hold the GIL.

Additionally, there was an issue with Fedora on a 32-bit system that was fixed in this [PR](
python/cpython#104811
), so I also ported the fix.

Reviewed By: carljm

Differential Revision: D46041553

fbshipit-source-id: 6502189f489ca6cf11949ecd93c044e5ebe4fd2c
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본