Skip to content

fix: lifetime issue cached filename - #2182

Merged
morrisonlevi merged 5 commits into
masterfrom
levi/filename-cache
Aug 2, 2023
Merged

fix: lifetime issue cached filename#2182
morrisonlevi merged 5 commits into
masterfrom
levi/filename-cache

Conversation

@morrisonlevi

@morrisonlevi morrisonlevi commented Jul 30, 2023

Copy link
Copy Markdown
Collaborator

Description

This issue hasn't shipped to customers, as the issue was only introduced in #1998 and it isn't included in any releases. The string table gets reset on each request, so the ZendFrame may reference invalid memory when sent across the channel.

With this, there are no reasons anymore to have a Cow<str> instead of a String for filename specifically, so I change that in the ZendFrame struct as well.

The filename cache slot is retained because the String::from_utf8_lossy is expensive enough to warrant caching it.

Readiness checklist

  • Changelog has been added to the release document.
  • Tests added for this feature/bug.

Reviewer checklist

  • Appropriate labels assigned.
  • Milestone is set.

@morrisonlevi morrisonlevi added 🐛 bug Something isn't working profiling Relates to the Continuous Profiler labels Jul 30, 2023
@morrisonlevi morrisonlevi added this to the 0.91.0 milestone Jul 30, 2023
@pr-commenter

pr-commenter Bot commented Jul 30, 2023

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2023-08-01 15:37:38

Comparing candidate commit 7e8d799 in PR branch levi/filename-cache with baseline commit caef966 in branch master.

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

scenario:walk_stack/1

  • 🟥 wall_time [+5.617µs; +5.618µs] or [+99.718%; +99.744%]

scenario:walk_stack/50

  • 🟥 wall_time [+8.956µs; +8.959µs] or [+137.387%; +137.426%]

scenario:walk_stack/99

  • 🟥 wall_time [+9.118µs; +9.121µs] or [+139.722%; +139.765%]

scenario:walk_stack_instructions/1

  • 🟥 instructions [+58.2K instructions; +58.2K instructions] or [+133.397%; +133.432%]

scenario:walk_stack_instructions/50

  • 🟥 instructions [+59.6K instructions; +59.6K instructions] or [+136.212%; +136.227%]

scenario:walk_stack_instructions/99

  • 🟥 instructions [+60.3K instructions; +60.3K instructions] or [+138.409%; +138.423%]

The function part of the cache already had fixed this issue, but it
seems the filename portion was overlooked.

With this, there are no reasons anymore to have a Cow<str> instead of
a String for filename specifically, so I change that in the ZendFrame
struct as well.

perf: drop filename from the run time cache

Since it was now getting copied every time, and the logic to obtain
it is not complex, it doesn't justify the usage of the cache.

test: attempt to fix flaky test
@morrisonlevi
morrisonlevi force-pushed the levi/filename-cache branch from 0529ea3 to e4584a8 Compare July 31, 2023 22:21
@morrisonlevi
morrisonlevi marked this pull request as ready for review August 1, 2023 14:20
@morrisonlevi
morrisonlevi requested review from a team as code owners August 1, 2023 14:20
Comment thread profiling/src/php_ffi.c
Comment thread profiling/src/php_ffi.c
return cache_addr + ddog_php_prof_run_time_cache_handle;

#else
(void)func;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

question: what does this actually do?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

skip unused variable warnings

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, this is C convention to cause a variable to be used and therefore avoid a warning about an unused parameter/variable.

Comment thread profiling/src/profiling/stalk_walking.rs
@morrisonlevi
morrisonlevi merged commit 7448bca into master Aug 2, 2023
@morrisonlevi
morrisonlevi deleted the levi/filename-cache branch August 2, 2023 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working profiling Relates to the Continuous Profiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants