Closed
Bug 643885
Opened 14 years ago
Closed 14 years ago
Optimize nsContentUtils::RemoveScriptBlocker to minimize the number of memmove's
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla6
People
(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)
References
Details
(Keywords: dev-doc-complete, perf)
Attachments
(2 files, 1 obsolete file)
1.61 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
6.56 KB,
patch
|
benjamin
:
review+
|
Details | Diff | Splinter Review |
nsContentUtils::RemoveScriptBlocker removes the script blockers run on by one, each of which incurs a memmove. This is basically unnecessary. If we have an nsCOMArray API for removing multiple consecutive elements, we can optimize it by just doing this work at the end of the loop, I guess.
This was noted when profiling the testcase in bug 237842.
Comment 1•14 years ago
|
||
nsCOMArray doesn't have such an API, but nsTArray does. We should switch, imo.
Yeah. I'd like to move towards making nsCOMArray just be a typedef of nsTArray<nsCOMPtr<T>>, but that'll likely take longer than we want to wait for.
Comment 3•14 years ago
|
||
Also, IIRC nsCOMArray releases its internal buffer when doing Clear().
So it might make sense to for it to keep some buffer alive all the time -
say when the buffer is less than 64 items or something.
Assignee | ||
Comment 4•14 years ago
|
||
(In reply to comment #1)
> nsCOMArray doesn't have such an API, but nsTArray does. We should switch, imo.
nsVoidArray (the underlying store) supports it (nsVoidArray::RemoveElementsAt), which is why I said that we could add an equivalent nsCOMArray API.
Assignee | ||
Comment 5•14 years ago
|
||
(In reply to comment #3)
> Also, IIRC nsCOMArray releases its internal buffer when doing Clear().
> So it might make sense to for it to keep some buffer alive all the time -
> say when the buffer is less than 64 items or something.
That sounds like a good idea to me. Can you please file a bug for that?
Assignee | ||
Comment 6•14 years ago
|
||
Assignee | ||
Comment 7•14 years ago
|
||
Attachment #521122 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 8•14 years ago
|
||
Hmm, this second patch manages to leak all of the objects that someone might think of! I don't understand the leak yet.
Assignee | ||
Comment 9•14 years ago
|
||
My implementation of RemoveObjectsAt had a bug which showed up when trying to delete the last item in the array (i.e., RemoveObjectsAt(count-1,1)). This version of the patch fixes the bug and adds a test for it.
Attachment #521116 -
Attachment is obsolete: true
Attachment #521116 -
Flags: review?(benjamin)
Attachment #521268 -
Flags: review?(benjamin)
Comment 10•14 years ago
|
||
Comment on attachment 521122 [details] [diff] [review]
Part 2: Optimize nsContentUtils::RemoveScriptBlocker to minimize the number of memmove's
r=me
Attachment #521122 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 11•14 years ago
|
||
bsmedberg: ping?
Updated•14 years ago
|
Attachment #521268 -
Flags: review?(benjamin) → review+
Assignee | ||
Comment 12•14 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/57494f03fba3
http://hg.mozilla.org/mozilla-central/rev/ff2e6be782da
(dev-doc-needed for the new nsCOMArray API)
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite+
Keywords: dev-doc-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
Comment 13•14 years ago
|
||
Documentation updated:
https://developer.mozilla.org/en/XPCOM_array_guide#Deleting_objects
Also added a mention to Firefox 6 for developers.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•