Closed Bug 661768 Opened 13 years ago Closed 2 years ago

Defer history lookup on anchor creation

Categories

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

task

Tracking

()

RESOLVED FIXED
Performance Impact low

People

(Reporter: jesup, Unassigned)

References

(Blocks 1 open bug)

Details

When doing BindToTree() for an anchor element in the Dromaeo tests, it calls UpdateState() which calls LinkState(), which looks up the URI in a history hash.  This blocks possible performance improvements which depend on deferring URI normalization (see  bug 268200).

Since displaying a link requires coloring it properly, it will probably need to be normalized when displayed.  If having been visited affects layout, then it would need to be normalized on reflow/layout.  If JS code checks the link status, that would require normalization.  There are probably other cases, and I'm not sure it can be deferred enough to make bug 268200's plan to defer normalization effective (at least in non-benchmark cases).

(filed at bz's request)
Assignee: nobody → bzbarsky
Blocks: 268200
General plan is to try constructing the URI as we do now but not starting the history lookup unless we're actually resolving style, so that unrelated state updates don't trigger the history lookup.
Assignee: bzbarsky → nobody
Component: Networking → DOM
Priority: -- → P1
QA Contact: networking → general
(Assuming you didn't really want to unassign)
Assignee: nobody → bzbarsky
Note from bug 268200 that it's also doing ResetLinkState() on UnBindFromTree, which causes a history operation.
Severity: normal → major
Priority: P1 → P2
Component: DOM → DOM: Core & HTML

I believe the combination of bug 1355540 and bug 1378218 fixed this. Does that look about right?

Assignee: bzbarsky → nobody
Flags: needinfo?(rjesup)

(In reply to Boris Zbarsky [:bzbarsky] from comment #4)

I believe the combination of bug 1355540 and bug 1378218 fixed this. Does that look about right?

Not sure... that cut the hashtable overhead (using segmentedvector/etc) and removed some other overhead, but I don't think that addresses comment 0 or comment 1. A profile might help.

The idea here was to unblock some of the ideas like https://bugzilla.mozilla.org/show_bug.cgi?id=268200#c13

Flags: needinfo?(rjesup)
Whiteboard: [qf]

Looking at the code, the key is that HTMLAnchorElement::BindToTree now calls RegisterPendingLinkUpdate which:

  1. Calls SetHasPendingLinkUpdate(), which prevents any history lookup stuff happening until ClearHasPendingLinkUpdate. See the HasPendingLinkUpdate() check in Link::LinkState(), in particular.
  2. Adds the link to a list of links to update, which does not involve getting its URI or doing history lookups.
  3. Schedules an idle-priority runnable that for each link calls ClearHasPendingLinkUpdate and then if the link is still in the doc calls UpdateLinkState, which is what triggers the history lookup.

So the practical effect is that we defer the history lookup to an idle runnable, which seems like it addresses what comment 0 and comment 1 were about, except more so: even the URI construction is deferred. That's helped by the fact that the "is a link" check now just checks for nonempty href rather than checking that the href could in fact be turned into a valid nsIURI.

Given that this was first brought up 9 years ago, maybe we need some new data to support whether this is still useful? Also, should this be marked as a defect? It sounds like an enhancement instead. Marking it as qf:p3 unless we have some recent data to support it's need.

Whiteboard: [qf] → [qf:p3]
QA Whiteboard: qa-not-actionable
Performance Impact: --- → P3
Whiteboard: [qf:p3]

In the process of migrating remaining bugs to the new severity system, the severity for this bug cannot be automatically determined. Please retriage this bug using the new severity system.

Severity: major → --
Type: defect → task
Priority: P2 → --

I believe this is fixed.

Note also that layout shouldn't depend on :visited state anymore. We now only allow :visited rules to change the link color now, and we lie about the color to JS consumers for security reasons.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED

Yes, I think comment 6 agrees that this is fixed.

(In reply to Kris Maglione [:kmag] from comment #9)

Note also that layout shouldn't depend on :visited state anymore. We now only allow :visited rules to change the link color now, and we lie about the color to JS consumers for security reasons.

That was true when this was filed; see bug 147777 comment 249, which predates this bug by about 14 months.

(In reply to David Baron :dbaron: from comment #10)

Yes, I think comment 6 agrees that this is fixed.

(In reply to Kris Maglione [:kmag] from comment #9)

Note also that layout shouldn't depend on :visited state anymore. We now only allow :visited rules to change the link color now, and we lie about the color to JS consumers for security reasons.

That was true when this was filed; see bug 147777 comment 249, which predates this bug by about 14 months.

I know, I checked. But comment 0 mentioned reflow/layout and no other comment mentioned it, so I thought I should for the sake of completion.

You need to log in before you can comment on or make changes to this bug.