Closed Bug 606937 Opened 14 years ago Closed 10 years ago

Processing many light-weight Gecko events spends too much time in event loop handling

Categories

(Core :: Widget: Cocoa, defect)

All
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: mstange, Assigned: smichaud)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

See attachment 485706 [details] for a Shark profile.

After dispatching a large number of Gecko events (e.g. nsRunnables), processing the Gecko event queue spends a lot of time outside the processing of the actual events. For example, in the profile mentioned above (from bug 606932), only 8% of the time is actually spent running the event. The rest is eaten up by the native event loop.

I'm not sure what the native event loop does there. It does a lot of mach_port_insert/extract_member, whatever that means... maybe synchronization with some kind of central event server?
More speculation: Does the fact that we keep posting native events in nsAppShell::ProcessGeckoEvents (using [NSApp postEvent:...]) have something to do with it? How ofter do we post these dummy events? For every Gecko event?

We definitely need a testcase here. Scenarios where I've seen large numbers of Gecko events are:
 - SMIL time events in bug 606932
 - Audio events
 - Worker messages, e.g. in the testcase for bug 600443
 - window.postMessage, e.g. http://dbaron.org/mozilla/zero-timeout
> More speculation: Does the fact that we keep posting native events
> in nsAppShell::ProcessGeckoEvents (using [NSApp postEvent:...]) have
> something to do with it?

The obvious thing to try is to comment out the code that sends these
events, and see what happens.

You may get event starvation and hangs ... which would presumably
invalidate any tests that triggered them.  But then again you might
not, especially if the tests are very narrowly targeted.

I'd be curious to see your results.
For what it's worth, on a typical profile that involves pageload/painting/etc, about 10% of the time is spent in this native event loop gunk, on Mac.  I suppose I should have filed about this before; I thought it was just the way it was.
Blocks: 583069
Bug 996848 fixed this. Nice!
Assignee: nobody → smichaud
Status: NEW → RESOLVED
Closed: 10 years ago
Depends on: 996848
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: