Closed
Bug 52991
Opened 25 years ago
Closed 4 years ago
Remove static (large) buffers from the HTML -> text converter
Categories
(Core :: DOM: Serializers, defect, P3)
Core
DOM: Serializers
Tracking
()
RESOLVED
INACTIVE
People
(Reporter: bratell, Unassigned)
References
Details
(Keywords: memory-footprint)
Attachments
(1 file, 3 obsolete files)
|
8.95 KB,
patch
|
akkzilla
:
review+
|
Details | Diff | Splinter Review |
Right now nsHTMLToTXTSinkStream keeps two stacks with a fixed size. Since they
are fixed size they must be quite big to not hit the limit. This causes the need
for more memory than necessary and there is still a small risk for failure.
I did a fix to replace the stacks by dynamic ones and with that reduce initial
stack size to something closer to what's really needed.
This is no big thing. It will save a couple of KB of memory for every
copy/paste, mail send, textfield extraction and whenever else the converter is
used and that's it.
I will attach the patch here, but it's untested since I cannot run Mozilla since
a couple of days (registration problem caused by the jar packaging?). I will do
the tests when that problem has gone away.
| Reporter | ||
Comment 1•25 years ago
|
||
Comment 2•25 years ago
|
||
Daniel, are you hitting bug 52879?
Why
+ mTagStack = new nsHTMLTag[mTagStackSize];
but
+ mOLStack = new PRInt32[InitialOLStackSize];
?
Why
+ if(aNewSize == 0)
+ aNewSize = 1;
and not
+ if(aNewSize == 0)
+ return NS_OK;
?
Don't you want to bail out?
+ NS_ASSERTION(mTagStackIndex < mTagStackSize,
+ "Corrupt stackindex. Pointing outside stack!");
Why the change in nsHTMLContentSinkStream? (You know that it is used by the
browser? So, you better know it works.)
Comment 3•25 years ago
|
||
Did I mention that fixing this bug (and similar ones) is a good idea?
| Reporter | ||
Comment 4•25 years ago
|
||
The inclusion of nsHTMLContentSinkStream.cpp was a mistake. I forgot to edit the
diff output.
The reason I didn't bail out with a return was that this is an indication of
major courruption and I thought that if I return we only would crash somewhere
else. Maybe my reasoning is wrong.
Status: NEW → ASSIGNED
Comment 5•25 years ago
|
||
Note that assertions are only evaluated for DEBUG builds, so in production
builds, your test would do nothing at all. Returning with an error is safer
then, I think. If you want, you can do both.
if (mTagStackIndex >= mTagStackSize)
{
NS_ASSERTION(PR_FALSE, "Corrupt stackindex: |mTagStackIndex >= mTagStackSize|.
Pointing outside stack!");
return NS_ARRRGGG;
}
| Reporter | ||
Comment 6•25 years ago
|
||
| Reporter | ||
Comment 7•25 years ago
|
||
I've attached a fix that I think is good. I've tested it now (had a corrupt
component.reg before) and it works as I want. It reduces heap allocations by
about 2 KB. The binary increases a couple of 100 bytes.
I don't know though if this is something Netscape will want for NS6 so I think
I'll wait till after they branched before checking it in. I will take rewiews
though. :-)
Severity: normal → minor
Whiteboard: FIX IN HAND
Target Milestone: --- → M20
| Reporter | ||
Updated•25 years ago
|
Target Milestone: M20 → mozilla0.9
| Reporter | ||
Comment 8•25 years ago
|
||
I just want to say that one reason I haven't gone further with this is that the
decreased memory used is replaced with an increase in code size of almost the
same amount. I'm not sure if it's worthwhile.
| Reporter | ||
Comment 9•25 years ago
|
||
Are there no growable arrays in xpcom? Like std::vector<int> or something similar?
Whiteboard: FIX IN HAND
| Reporter | ||
Updated•25 years ago
|
Target Milestone: mozilla0.9 → mozilla0.9.1
Comment 10•25 years ago
|
||
bug 38173 is proposing ns[Auto]UInt32Array which might be useful here.
| Reporter | ||
Comment 11•25 years ago
|
||
Yes, that's why bug 38173 is listed as a blocker for this. I'm waiting... :-)
Comment 12•25 years ago
|
||
bug 38173 doesn't have a target milestone set. so I'm going to unset the
milestone on this one. if we work out a schedule for getting the
dependency bug and this one fixed then lets retarget this bug
when we think it will land.
adding kandrot to the cc list. maybe he can help on resovling the
dependency.
Updated•25 years ago
|
Target Milestone: mozilla0.9.1 → ---
| Reporter | ||
Comment 13•24 years ago
|
||
I have a new patch that uses the NS_PTR_TO_INT32 macro and an NS_PTR_TO_HTMLTAG
macro to get around the need for an int array by using the ordinary nsVoidArray.
The old patch was well, quite old anyway.
Harish, can you review it? The benefits are that we can take arbitary size input
while using 2KB less memory in the common case.
jst, can you sr it?
Keywords: footprint
| Reporter | ||
Comment 14•24 years ago
|
||
Attachment #14885 -
Attachment is obsolete: true
Attachment #15019 -
Attachment is obsolete: true
Comment 15•23 years ago
|
||
Comment on attachment 60035 [details] [diff] [review]
Modern patch using nsVoidArray
DOM folks, any stamps on the patch? Seems to look clean and good (if still
up-to-date).
| Reporter | ||
Comment 16•23 years ago
|
||
The attached patch is not mergeable but I have kept it up to date in my local
tree all the time so here is a usable patch.
Attachment #60035 -
Attachment is obsolete: true
| Reporter | ||
Updated•23 years ago
|
Attachment #104606 -
Flags: superreview?(jst)
Attachment #104606 -
Flags: review?(akkana)
Comment 17•23 years ago
|
||
Comment on attachment 104606 [details] [diff] [review]
Resynched with the trunk
Sorry, I spaced on the review request.
> #define NS_PTR_TO_HTMLTAG(x) NS_STATIC_CAST(nsHTMLTag, NS_PTR_TO_INT32(x))
> #define NS_HTMLTAG_TO_PTR(x) NS_INT32_TO_PTR(NS_STATIC_CAST(PRInt32, (x)))
Wow, I wish we had a class that didn't require this. I guess what you're doing
is safe (you're storing integers representing html tags in void* spaces,
right?) and I don't know of another way using our classes, but ... ew.
The patch as is doesn't compile for me. You need to add:
#include "nsVoidArray.h"
in nsPlainTextSerializer.h.
>+ PRInt32 nextToLastTagIndex = mTagStack.Count()-2;
>+ if (nextToLastTagIndex >= 0 && IsInOL()) {
nextToLastTagIndex is never used after this; wouldn't it be more
straightforward to just check whether mTagStack.Count() >= 2 and skip setting
the variable?
r=akkana with the nsVoidArray.h include added (and the nextToLastTagIndex
change at your discretion).
Attachment #104606 -
Flags: review?(akkana) → review+
| Reporter | ||
Comment 18•23 years ago
|
||
Yes, the nsVoidArray.h inclusion is needed since ParserService caching was
removed. I think that this patch might need an overhaul after bug 180996 is
fixed. The current patch there uses a stack that would be parallell to the tag
stack here. Those should probably be merged somehow, but right now I'm more
eager to get bug 180996 fixed and will deal with the consequences later.
| Reporter | ||
Comment 19•23 years ago
|
||
Comment on attachment 104606 [details] [diff] [review]
Resynched with the trunk
Canceling sr request. This patch will have to be updated after landing of some
other patches I prioritize higher than this.
Attachment #104606 -
Flags: superreview?(jst)
Comment 20•23 years ago
|
||
Daniel, can this patch be brought up-to-date or are you still waiting on the
other patches?
| Reporter | ||
Comment 21•23 years ago
|
||
It could quite easily be brought up to date if I just hade some time to do it. :-(
Comment 22•18 years ago
|
||
Daniel, are you still planning on working on this?
Updated•16 years ago
|
QA Contact: sujay → dom-to-text
Comment 23•4 years ago
|
||
The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.
Assignee: bratell → nobody
Status: ASSIGNED → NEW
Updated•4 years ago
|
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INACTIVE
You need to log in
before you can comment on or make changes to this bug.
Description
•