Mobile/Powersaving/Wakeups/Debugging: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 1: Line 1:
= Overview =
'Wakeups' are instances where a thread enters activity. Each such wakeup stops the CPU from sleeping. Several short wakeups are much worse than a single long wakeup, because each wakeup will prevent sleeping for a short time afterwards, and sleeping can save a lot of power (see powertop docs). So avoiding wakeups is important, and if they are unavoidable then 'clumping' them together is preferable to scattering them at semi-random times.
== Finding Wakeups ==
== Finding Wakeups ==



Revision as of 20:26, 28 May 2010

Finding Wakeups

One approach to finding wakeups is to add some debug prints to the relevant NSPR functions, which are PR_WaitCondVar (in nsprpub/pr/src/pthreads) and so forth, e.g.

PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout)
{
   printf("PR_WaitCondVar %x ; %d\n", cvar, timeout);

This can give you some useful information when running. To further detect what code is calling the function, consider running the debugger and placing breakpoints there, then looking at a stack trace.

Debugger tips:

  • Placing a breakpoint in nsTimerImpl.cpp::Fire(), where it decides what callback to call ("switch (callbackType) {", currently line 425), can be very useful - simply step forward a little until you see what is being called.
  • Note that working in the debugger, with freezing/continuing etc., will mess up the normal wakeup timing. So after discovering the relevant suspects using the debugger, consider adding debug printouts and running outside of the debugger to see which are actually more important in practice.

Current Wakeups of Notice

  • 1 wakeup/sec: WatchdogMain runs JS_TriggerOperationCallback on all JS contexts, which is used for GC, infinite loop detection, etc.