Closed Bug 1713378 Opened 5 years ago Closed 5 years ago

Use a better pointer for the Android UI thread's stack top when registering with the profiler

Categories

(GeckoView :: General, defect)

Unspecified
All
defect

Tracking

(firefox91 fixed)

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: bugzilla, Assigned: bugzilla)

References

(Blocks 1 open bug)

Details

(Whiteboard: [geckoview:m91])

Attachments

(1 file)

We currently register the Android UI thread with the profiler using the PROFILER_REGISTER_THREAD macro.

This macro uses the address of a local variable as an estimate for the top of the thread's call stack. The profiler's sampling thread does not walk the stack any further above this value.

This works fine most of the time, as it's usually one of the first things that we do when running a new thread.

On the other hand, the Android UI thread already has a bunch of stuff on the stack by the time we go to set this, plus we have two or three calls already on the stack as well. Using our current stack frame as an estimate for the top of the stack results in the profiler omitting numerous frames from the Android UI thread because it mistakenly believes that it needs to stop walking the stack sooner than it actually needs to!

Instead of using the macro, I'd like us to use pthreads to resolve the real stack top and supply that pointer to the profiler instead.

We were previously registering the Android UI thread with the profiler using
the PROFILER_REGISTER_THREAD macro.

This macro uses the address of a local variable as an estimate for the top of
the thread's call stack. The profiler's sampling thread does not walk the stack
any further past this value.

This works fine most of the time, as it's usually one of the first things that
we do when running a new thread.

On the other hand, the Android UI thread already has a bunch of stuff on the
stack (including VM frames) by the time we go to set this, plus we have two or
three of our own calls already on the stack as well. Using the current stack
frame as an estimate for the top of the stack results in the profiler omitting
numerous frames from the Android UI thread because it mistakenly believes that
it needs to stop walking the stack sooner than it actually needs to!

Instead of using the macro, this patch uses pthreads to resolve the real stack
top and supplies that pointer to the profiler instead.

Pushed by aklotz@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2746dcf5094b Use a more accurate stack top pointer when registering the Android UI thread with the profiler; r=gerald,geckoview-reviewers,owlish
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: