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

[Profiler] First sample sometimes has timestamp of zero #1368

Open
2 tasks
Beanyy opened this issue Apr 5, 2024 · 1 comment
Open
2 tasks

[Profiler] First sample sometimes has timestamp of zero #1368

Beanyy opened this issue Apr 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Beanyy
Copy link
Contributor

Beanyy commented Apr 5, 2024

Bug Description

When using the Profiler, sometimes the first sample has a timestamp of zero, where the other samples have a timestamp very far off from zero. When viewing the trace, the total duration ends up being very long (like 100s) even though the capture of the trace was just 5s long.

I've narrowed down the issue to right here:
https://github.com/facebook/hermes/blob/main/lib/VM/Profiler/SamplingProfilerSampler.cpp#L74

If the code path reaches here for the first sample, sampleStorage_ is still in its initial state without being assigned a new sample, and then that is appended to the sampledStacks_ array. Locally, I have fixed this issue by just adding return true after sampledStackDepth_ = 0;, but I'm unsure if that's the right approach to resolving this issue and would like some guidance on how you think this should be resolved.

Thanks

  • I have run gradle clean and confirmed this bug does not occur with JSC
  • The issue is reproducible with the latest version of React Native.

Hermes git revision (if applicable):
React Native version:
OS:
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64):

Steps To Reproduce

code example:

The Expected Behavior

@Beanyy Beanyy added the bug Something isn't working label Apr 5, 2024
@neildhar
Copy link
Contributor

neildhar commented Apr 9, 2024

Thanks for reporting this, it certainly seems like a bug when this codepath is hit, since the timestamp is uninitialised. However, I'm slightly surprised that you're hitting it at all, given that there aren't really any cases where the profiler is suspended but there is no recorded stack available. Could you share more about how you're getting into that state?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants