DataDog / dd-trace-php

Datadog PHP Clients
https://docs.datadoghq.com/tracing/setup/php
Other
481 stars 149 forks source link

perf(profiling): shrink the size of ZendFrame #2709

Open morrisonlevi opened 3 weeks ago

morrisonlevi commented 3 weeks ago

PROF-9925

Description

Previously, each frame was 7 64 bits. They are now 3 64 bits, at the cost that there are slightly more String copies than before. This PR is an attempt to see if this trade-off is worth it.

The current status is that when things are fetched from cache, or if the inserting thing returns a borrowed Cow<str> such as for filenames, then we have the same number of copies as before. Function names are going to return an owned Cow<str>, though, and in this case we have an extra copy compared to before. The benchmarks that the PR bot posts do not capture this case.

Reviewer checklist

pr-commenter[bot] commented 3 weeks ago

Benchmarks

Benchmark execution time: 2024-06-12 23:26:42

Comparing candidate commit a8fc7ffaf2c224eb36fa088733a718e3f1bada75 in PR branch levi/smaller-frames with baseline commit 9f4a6a50e8c487127431af623037a08d9dc1c2b1 in branch master.

Found 5 performance improvements and 0 performance regressions! Performance is the same for 24 metrics, 7 unstable metrics.

scenario:walk_stack/1

scenario:walk_stack/99

scenario:walk_stack_instructions/1

scenario:walk_stack_instructions/50

scenario:walk_stack_instructions/99

codecov-commenter commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 79.40%. Comparing base (9f4a6a5) to head (a8fc7ff).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2709/graphs/tree.svg?width=650&height=150&src=pr&token=eXio8H7vwF&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog)](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2709?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) ```diff @@ Coverage Diff @@ ## master #2709 +/- ## ============================================ + Coverage 79.12% 79.40% +0.28% Complexity 2212 2212 ============================================ Files 201 201 Lines 22451 22544 +93 ============================================ + Hits 17764 17901 +137 + Misses 4687 4643 -44 ``` | [Flag](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2709/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | Coverage Δ | | |---|---|---| | [tracer-extension](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2709/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `78.63% <ø> (+0.48%)` | :arrow_up: | | [tracer-php](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2709/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `80.52% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#carryforward-flags-in-the-pull-request-comment) to find out more. [see 12 files with indirect coverage changes](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2709/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2709?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2709?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog). Last update [9f4a6a5...a8fc7ff](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2709?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog).