Open Bug 304870 Opened 19 years ago Updated 2 years ago

Severe performance issue leaving page when many images all point to the same URL

Categories

(Core :: Graphics: ImageLib, defect)

x86
Linux
defect

Tracking

()

People

(Reporter: bzbarsky, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Keywords: perf)

STEPS TO REPRODUCE:

1)  Download the zip file at https://bugzilla.mozilla.org/attachment.cgi?id=192825
2)  Unzip it
3)  Load tree.html from the zip
4)  Leave the page
5)  If fastback is enabled, visit as many pages as needed to evict the document
    from its cache.  I suggest just disabling fastback to ease testing.

EXPECTED RESULTS:  Leaving the page is bearable

ACTUAL RESULTS:  Leaving the page is very very slow.  On my hardware (p3-733) it
takes minutes.

DETAILS:  I did a profile.  The profile results were:

Total hit count: 1996872
Count %Total  Function Name
1851978   92.7     memmove

and the call to memmove happens from nsVoidArray::RemoveElementsAt, called from
nsVoidArray::RemoveElement, called from imgRequest::RemoveProxy, called from
imgRequestProxy::Cancel, called from nsImageLoadingContent::~nsImageLoadingContent.

The basic issue is that images are torn down in creation order, so we remove all
entries from the array one at a time starting from the front.  This means O(N)
calls to memmove, which means the total time taken by memmove is O(N^2) in the
number of images using the imgRequest, assuming that memmove is O(N) in the size
of the memory being moved.

What I'd suggest is that we use a setup similar to the one nsRuleNode uses --
use an array while we have a small number of imgRequestProxys, then switch to
using a hashtable.  Does that sound reasonable?
seems reasonable to me.
Assignee: pavlov → nobody
QA Contact: imagelib
joe, do we have someone who can take this?
Either Bobby or me; I hope to be able to get back to Imagelib stuff soon.
Depends on: 978762
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.