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

RESOLVED FIXED

Status

MailNews Core
Networking: IMAP
RESOLVED FIXED
12 years ago
9 years ago

People

(Reporter: Hans-Andreas Engel, Assigned: Hans-Andreas Engel)

Tracking

({fixed1.8.1, perf})

Trunk
fixed1.8.1, perf
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

12 years ago
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.
(Assignee)

Updated

12 years ago
Status: NEW → ASSIGNED
(Assignee)

Comment 1

12 years ago
Created attachment 195364 [details] [diff] [review]
Delay initialization of tokenizer (strdup)

Delay initialization of tokenizer (strdup) until either |AdvanceToNextToken| or
|AdvanceTokenizerStartingPoint| is invoked.
(Patch for Bug 307605 should be applied first.)
(Assignee)

Updated

12 years ago
Depends on: 307605
(Assignee)

Updated

12 years ago
Attachment #195364 - Flags: review?(bienvenu)
(Assignee)

Comment 2

12 years ago
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). 
(Assignee)

Updated

12 years ago
Blocks: 313038

Comment 3

12 years ago
fix checked in, thanks!
Status: ASSIGNED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → FIXED
(Assignee)

Comment 4

12 years ago
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 5

12 years ago
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+
(Assignee)

Updated

12 years ago
Keywords: fixed1.8.1
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.