Three Monkeys, Three Typewriters, Two Days

August 7, 2006

Profiling reflow branch

I recently did a profile of the reflow branch on a DHTML testcase. This particular one uses pretty much no text, so cairo is not a big factor, at least on Linux, but just for the record, the profile was done with a non-cairo build. The results were as follows:

Total hit count: 236663

Things taking time under the main event loop:

 172167 js_Execute (run off a setTimeout)
  36892 nsCSSFrameConstructor::RestyleEvent::Run
  12566 nsViewManager::Refresh
   9776 PresShell::ProcessReflowCommands
   4458 nsProxyCallEvent::Run

Summary breakdown of js_Execute:

  34531 Parsing CSS; about a third is converting strings to numbers.
 ~26000 Getting the nodes to operate on (mostly classinfo and xpconnect)
 ~20000 Handling the actual attribute change in content code, together
        with document observer notifications.
 ~16000 XPConnect stuff.
  15000 converting numbers to strings in JS.
  13053 security checks
   4390 jsd_FunctionCallHook
 ~30000 various other XPConnect and JS overhead(?).

Detailed breakdown of js_Execute:

94392 XPCWrappedNative::CallMethod
14975 js_ValueToString (handling the expression foo + "px").
15238 XPC_WN_Helper_GetProperty (mostly getting the [i] item of a list)
 9726 XPC_WN_Helper_NewResolve (again, mostly resolving on a list)
 4390 jsd_FunctionCallHook
 2500 XPCCallContext::XPCCallContext
 1000 XPCNativeMember::GetCallInfo
 1000 XPCCallContext::~XPCCallContext

Both XPC_WN_Helper_NewResolve and XPC_WN_Helper_GetProperty are mostly XPConnect code -- creating and destroying XPCCallContexts and wrapping natives.

Further breakdown of XPCWrappedNative::CallMethod:

 67320 XPTC_InvokeByIndex
 13053 nsScriptSecurityManager::CheckPropertyAccessImpl
  5800 XPCConvert::NativeInterface2JSObject
  1533 converting JSString to nsAString
  1196 XPCCallContext::CanCallNow
  1191 GetInterfaceTypeFromParam

Further breakdown of XPTC_InvokeByIndex:

 34531 CSSParserImpl::ParseProperty
  4009 nsFrameManager::HasAttributeDependentStyle
  1213 nsContentUtils::HasMutationListeners
  1608 PresShell::GetPrimaryFrameFor
  1001 nsAttrAndChildArray::SetAndTakeAttr
   926 nsCSSFrameConstructor::PostRestyleEvent
   231 PresShell::PostReflowEvent
 ~4000 other content overhead

Further breakdown of CSSParserImpl::ParseProperty:

  11314 nsString::ToFloat
   4022 nsCSSExpandedDataBlock::Expand
   3922 nsCSSExpandedDataBlock::Compress
   2595 nsCSSKeywords::LookupKeyword
   2346 nsSubstring::Replace
    750 nsCSSScanner::GatherIdent
Posted by bzbarsky at August 7, 2006 8:15 PM