Closed Bug 307615 Opened 15 years ago Closed 15 years ago

Significantly reduce memory allocations for IMAP mail download by improving |nsIMAPGenericParser::AdvanceToNextLine()|

Categories

(MailNews Core :: Networking: IMAP, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: engel, Assigned: engel)

References

Details

(Keywords: fixed1.8.1, perf)

Attachments

(1 file)

Note that mail messages are read in line-by-line via calls to
|AdvanceToNextLine()|, see
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/mailnews/imap/src/nsImapServerResponseParser.cpp&rev=1.123&root=/cvsroot#2706
Note that in |AdvanceToNextLine()|, a |strdup| of every line is made in order to
be able to tokenize the line later.  However, this copy is never needed, since
no tokenization takes place while downloading the mail message.

This means that every incoming mail line triggers an unnecessary memory
allocation (!), e.g. about 20,000 extra allocations for downloading a 1 MB
attachment.  This should be avoided.
Status: NEW → ASSIGNED
Delay initialization of tokenizer (strdup) until either |AdvanceToNextToken| or
|AdvanceTokenizerStartingPoint| is invoked.
(Patch for Bug 307605 should be applied first.)
Depends on: 307605
Attachment #195364 - Flags: review?(bienvenu)
Note that the suggested patch does not alter the behavior of
|nsIMAPGenericParser|.  Particular care is taken when empty lines are parsed
(the current behavior is somewhat non-intuitive and should probably be changed
in the future; however, this should be examined in a different bug report). 
Blocks: 313038
fix checked in, thanks!
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
On a one-year-old computer, while downloading a large attachment of an IMAP
message with Thunderbird (the 30MB mozilla source code is very useful for such
tests), the CPU usage is roughly 5-10% lower on todays build than it is on
1.5b2; probably due to this patch.
Comment on attachment 195364 [details] [diff] [review]
Delay initialization of tokenizer (strdup)

marking reviews.
Attachment #195364 - Flags: superreview+
Attachment #195364 - Flags: review?(bienvenu)
Attachment #195364 - Flags: review+
Keywords: fixed1.8.1
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.