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

Replace compiled view paths in profiles #747

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stayallive
Copy link
Collaborator

@stayallive stayallive commented Aug 1, 2023

This works with: getsentry/sentry-php#1574, and is a PoC to show what that PR could be used for.

It replaces compiled view paths with their non-compiled paths (the ones you would actually look at in your editor).

Todo:

  • [4.x] Profiler frame processor sentry-php#1574
  • Check and make sure we should replace filename / function and not more / other info
  • When zero-downtime deployments are in play the compiled path can be outside the base_path, we might need to add realpath(storage_path()) as a prefix path to fix this. This requires some more testing / investigating
  • Possibly memoize the results to prevent multiple I/O operations for the same path? (uses a little memory)

{
// Check if we are dealing with a frame for a cached view path
if (Str::startsWith($frame['filename'], '/storage/framework/views/')) {
$originalViewPath = $this->backtraceHelper()->getOriginalViewPathForCompiledViewPath($frame['abs_path']);
Copy link
Member

Choose a reason for hiding this comment

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

Could we benchmark the perf overhead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we could but not sure how to quantify, since this does a few I/O operations to read the view file. In this WIP I didn't implement memoizing which could reduce the amount of operations needed when a view is seen multiple times. I could run this code a few iterations on my machine and see what the result is, but it's always an increase since before we didn't do anything.

Copy link
Member

Choose a reason for hiding this comment

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

A rough ballpark would suffice.

@cleptric
Copy link
Member

This is becoming more relevant now, as we'll ship a new performance issue that alerts users about regressed function durations. Having the path to the actual view file would make these issues more actionable.

@stayallive
Copy link
Collaborator Author

If we get this to a nice state we can also re-use the code for #513 and #739.

@stayallive stayallive self-assigned this Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants