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

feat(profiling) allocation profiling for PHP ZTS #2506

Merged
merged 12 commits into from
Mar 20, 2024

Conversation

realFlowControl
Copy link
Member

@realFlowControl realFlowControl commented Feb 6, 2024

Description

PROF-8922 / #2070

This PR will bring allocation profiling to ZTS versions of PHP. In the "there is another custom handler installed" code path we are using an UnsafeCell for a thread local which is the cheapest way (evaluated at compile time and not runtime), as this is in the hot path (every allocation and free would borrow check at runtime).
We could argue that the case of another extension that has custom handlers installed is nearly non existing, so we could also be better safe then sorry, but OTOH I could not get it to crash.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@github-actions github-actions bot added the profiling Relates to the Continuous Profiler label Feb 6, 2024
@pr-commenter
Copy link

pr-commenter bot commented Feb 6, 2024

Benchmarks

Benchmark execution time: 2024-03-20 11:33:38

Comparing candidate commit 81fa090 in PR branch florian/allocation-zts with baseline commit 7c36868 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 18 metrics, 3 unstable metrics.

@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2024

Codecov Report

Merging #2506 (f7b21b0) into master (fc050ce) will increase coverage by 1.16%.
Report is 5 commits behind head on master.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2506      +/-   ##
============================================
+ Coverage     75.91%   77.07%   +1.16%     
  Complexity     2563     2563              
============================================
  Files           241      215      -26     
  Lines         27020    23048    -3972     
  Branches        976        0     -976     
============================================
- Hits          20511    17765    -2746     
+ Misses         5989     5283     -706     
+ Partials        520        0     -520     
Flag Coverage Δ
appsec-extension ?
tracer-extension 78.70% <ø> (ø)
tracer-php 75.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 26 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc050ce...f7b21b0. Read the comment docs.

@realFlowControl realFlowControl force-pushed the florian/allocation-zts branch 3 times, most recently from 4de9425 to 3cae5b2 Compare February 15, 2024 12:44
@realFlowControl realFlowControl force-pushed the florian/allocation-zts branch 2 times, most recently from 0d71d43 to e76dd1b Compare February 22, 2024 16:22
@realFlowControl realFlowControl marked this pull request as ready for review February 23, 2024 08:50
@realFlowControl realFlowControl requested a review from a team as a code owner February 23, 2024 08:50
@realFlowControl realFlowControl force-pushed the florian/allocation-zts branch 2 times, most recently from ea1d19c to fbdab6a Compare February 29, 2024 09:06
Copy link
Collaborator

@morrisonlevi morrisonlevi left a comment

Choose a reason for hiding this comment

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

I believe OnceCell with cell.get_or_init(|| unreachable!()) and re-creating the OnceCell on each request has good enough codegen to be able to use, and then we avoid the unsafe. Discussed this with Florian on Zoom and Slack.

@realFlowControl realFlowControl force-pushed the florian/allocation-zts branch from fbdab6a to 3a33646 Compare March 1, 2024 10:58
@realFlowControl realFlowControl force-pushed the florian/allocation-zts branch from 4c70d21 to 14ece3d Compare March 12, 2024 10:09
realFlowControl and others added 6 commits March 19, 2024 17:26
…or the heap and the previous function pointers (if any)
ci skip

For whatever reason, the linter fails in this macro. It can succeed
in macros sometimes, just not this one.
morrisonlevi and others added 5 commits March 19, 2024 17:26
Also merge prepare/restore zend heap fns into one field, since they
are always used together, and allows us to use the new macro without
fetching them twice.
@realFlowControl realFlowControl force-pushed the florian/allocation-zts branch from 3821da2 to 155d1ca Compare March 19, 2024 16:26
@realFlowControl realFlowControl force-pushed the florian/allocation-zts branch from af595b3 to 81fa090 Compare March 20, 2024 11:22
@realFlowControl realFlowControl merged commit 3e9327b into master Mar 20, 2024
589 checks passed
@realFlowControl realFlowControl deleted the florian/allocation-zts branch March 20, 2024 15:41
@github-actions github-actions bot added this to the 0.99.0 milestone Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
profiling Relates to the Continuous Profiler tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants