Closed Bug 1844432 Opened 2 years ago Closed 2 years ago

On the Speedometer 3 "NewsSite" subtests, HTMLImageElement spends too much time creating URLs

Categories

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

defect

Tracking

()

RESOLVED FIXED
117 Branch
Tracking Status
firefox117 --- fixed

People

(Reporter: mstange, Assigned: emilio)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sp3])

Attachments

(2 files)

On the Speedometer3 subtest "NewsSite-Next", one of our biggest buckets for improvement is the time under Node.appendChild. This function spends most of its time creating nsIURI objects under HTMLImageElement::LoadSelectedImage.

Eliminating the performance difference in Node.appendChild should improve our score on this subtest by 1.7%.

You can run this test at https://shell--speedometer-preview.netlify.app/?suite=NewsSite-Next&iterationCount=1 .

Profiles:
Firefox: https://share.firefox.dev/3OkdCp4 (634 samples)
Chrome: https://share.firefox.dev/44LYYfM (176 samples, 3.6x faster)

The image URL is placeholder_light.jpg.

I think what's happening is that the actual load gets kicked off from setAttribute("src", "..."). Creating a URL there is fine. But then, when we add the node to the document, we end up in HTMLImageElement::BindToTree, which adds a script runner for HTMLImageElement::MaybeLoadImage (with aAlwaysLoad == false).

This results in a call to HTMLImageElement::LoadSelectedImage, which creates a new URI, notices that it matches the currently loaded source, and bails out.

Can we avoid creating URI objects in this case?

This issue also affects "NewsSite-Nuxt" ("u" instead of "e"), which would be improved by 2.7% if this were fixed.

Summary: On the Speedometer 3 subtest "NewsSite-Next", HTMLImageElement spends too much time creating URLs → On the Speedometer 3 "NewsSite" subtests, HTMLImageElement spends too much time creating URLs

Boris, is this something you could look into? (I noticed you looked at similar code in bug 1789475)

Flags: needinfo?(boris.chiou)

I'm not sure if it is possible to check if it matches the current source if we don't create the URI. For responsive image, we still have to select the correct image, so it may be pretty hard to skip the selection.

For creating URI object, I'm not sure if there are any other ways to simplify the check the matchness. Emilio, do you have any idea to avoid creating URI objects to improve this?

Flags: needinfo?(boris.chiou) → needinfo?(emilio)

I mean, in theory we can cache the parsed src attribute right? It probably makes sense.

Flags: needinfo?(emilio)
Assignee: nobody → emilio
Status: NEW → ASSIGNED
Keywords: leave-open
Severity: -- → S3
Priority: -- → P2
Keywords: leave-open
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 117 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: