Closed Bug 509889 Opened 15 years ago Closed 15 years ago

nsEventStateManager::GetContentState needs fast path to nsFocusManager::GetFocusedElement

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9.3a1
Tracking Status
status1.9.2 --- beta1-fixed

People

(Reporter: dbaron, Assigned: dbaron)

Details

(Keywords: perf)

Attachments

(1 file)

I just did a profile of new-browser-window performance in Firefox, and noticed that we're spending ~1% of the time (in whatever callgrind measures it in, which isn't real time, but it's something) doing nsEventStateManager::GetContentState's call to nsFocusManager::GetFocusedElement, which involves doing a QueryInterface from nsIContent to nsIDOMElement, returning the object, and then QIing the other way, and the ensuing reference counting and nsCOMPtr machinery.

(GetContentState is called a huge number of times because we call it during selector matching... and up-front on the assumption that it will be cheap.)

nsFocusManager ought to have a de-COM-taminated getter that returns a raw nsIContent pointer (not AddRef-ed).

Neil, do you have a preference between:

 (1) putting a second GetFocusedElement method on nsFocusManager and make nsFocusManager::GetFocusManager return an nsFocusManager instead of nsIFocusManager, or

 (2) adding a static nsFocusManager::GetFocusedElement method that specifically called an nsFocusManager method on sInstance (and only change the type of sInstance and not GetFocusManager)?
Number 1 sounds better.
Attached patch patchSplinter Review
Assignee: nobody → dbaron
Status: NEW → ASSIGNED
Attachment #394187 - Flags: review?(enndeakin)
Attachment #394187 - Flags: review?(enndeakin) → review+
http://hg.mozilla.org/mozilla-central/rev/f555ee21c59a
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Priority: -- → P3
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3
Comment on attachment 394187 [details] [diff] [review]
patch

Very simple de-COM-tamination performance win, fixing a regression from the focus manager landing.
Attachment #394187 - Flags: approval1.9.2?
catlee's performance monitoring scripts reported around a 1% Tdhtml win when this landed, but didn't report any Txul changes.  I landed it with some other large patches, though, but I think it's likely this one:
http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=e0cc032cb852&tochange=e6034ded61fd
Target Milestone: mozilla1.9.3 → mozilla1.9.3a1
Attachment #394187 - Flags: approval1.9.2? → approval1.9.2+
This reduced Tdhtml 1% on 1.9.2 as well (and landed there alone, so gets the credit all to itself).
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: