Closed Bug 558148 Opened 16 years ago Closed 16 years ago

Optimize nsContentUtils::HasMutationListeners

Categories

(Core :: DOM: Core & HTML, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: smaug, Assigned: smaug)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

This is called a lot, so better to make it as fast as possible. We can remove some virtual calls, and maybe inline the most commonly run code paths.
Attached patch a patch — — Splinter Review
The patch is something very-quickly-written. But with it the Dromaeo DOM attribute tests goes from 147-150 to 155-156 here. And HasMutationListeners did show up surprisingly much in the profile before inlining the relevant parts (inlining does of course increase the time spent in the caller). In any case, at least the GetInnerWindow() optimization should be done, and I think I want to do something similar for GetWindow(). The patch should affect especially to the SetAttr call. I pushed the patch to tryserver.
> from 147-150 to 155-156 here. Just the setAttribute test, or the whole set of 6? setAttribute seems to easily be 5% or so under HasMutationListeners over here, so I'd believe that.
The "DOM Attributes" test, whatever all it includes.
Comment on attachment 437932 [details] [diff] [review] a patch On 64bit linux I don't see as big change in attribute test, but still some, and this affects also to other DOM tests. We don't have awful lots of nsContentUtils::HasMutationListeners calls in the tree, so hopefully the code size change isn't too bad. In nsIDocument I put the *Internal to the end of the class, since nsIDocument is semi-public interface. In nsContentUtils it is just easier to keep *Internal() close to the non-*Internal().
Attachment #437932 - Flags: review?(bzbarsky)
> The "DOM Attributes" test, whatever all it includes. Ah, interesting. That has 6 tests, 4 of which actually touch the DOM (getAttribute/setAttribute and .id get/set). I guess your speedup was a tad less than 5%, which makes sense.
Attachment #437932 - Flags: review?(bzbarsky) → review?(jonas)
Comment on attachment 437932 [details] [diff] [review] a patch I'd be surprised if the inlining of HasMutationListeners actually helps. I think I'd prefer to do that if that in and of itself shows up as a benefit. so r-=me on that part for now. I do like the nsIDocument changes though. That's a good idea. r+=me on that part. Could we also remove the "IsOuterWindow()" and "!mOuterWindow" checks from nsPIDOMWindow::HasMutationListeners?
Attachment #437932 - Flags: review?(jonas) → review-
I'll test/profile the inlining part tomorrow.
OK, inlining HasMutationListeners doesn't seem to help too much. I'll push the nsIDocument change tomorrow and ask review for the HasMutationListeners inlining if I find out it useful enough.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Depends on: 1114991
No longer depends on: 1114991
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: