Closed
Bug 200389
Opened 23 years ago
Closed 22 years ago
better constness in mailnews/imap
Categories
(MailNews Core :: Networking: IMAP, defect)
MailNews Core
Networking: IMAP
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: ataylor, Assigned: ataylor)
Details
(Keywords: memory-footprint)
Attachments
(1 file, 2 obsolete files)
2.11 KB,
patch
|
sspitzer
:
review+
alecf
:
superreview+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4a) Gecko/20030401
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4a) Gecko/20030401
Some constants in mailnews/imap can be made const, ala alecf's
netscape.public.mozilla.seamonkey posting.
Reproducible: Always
Steps to Reproduce:
![]() |
Assignee | |
Comment 1•23 years ago
|
||
The patch just constifies consts and depointerizes string contants. I made the
string constants in EnvelopeTable arrays of chars rather than pointers; this
might not be the right thing to do. The other changes are independant if that
change is rejected.
![]() |
Assignee | |
Comment 2•23 years ago
|
||
Another patch that does the same for mailnews/addrbook.
![]() |
||
Comment 3•23 years ago
|
||
I don't like the envelope change (that will cause more static data to get
allocated than needed, won't it?) but the others look OK.
![]() |
Assignee | |
Comment 4•23 years ago
|
||
I collected some information about the above mentioned envelope change.
Incidentally, I changed the array size from 20 to 12, the minimum needed. These
numbers are from Linux.
The envelope change adds 32 bytes of .rodata, in addition to moving 64 bytes
from .data to .rodata (as measured with objdump -h). So, yes, it does add
footprint. However, it is worth noting that the number of shared library
relocation records is decreased by 10 (as measured with objdump -R). The
relocation records take up disk footprint, but not memory footprint; they also
effect startup time since the runtime loader must patch the in-memory image from
each record.
While this particular change is mostly irrelevent, I think the relocation
records are an important factor to consider when addressing footprint (at least
on ELF/Unix type OSes).
Comment on attachment 119224 [details] [diff] [review]
A patch that constifies some constants
>- const char *name;
>+ const char name[20];
Why?
![]() |
Assignee | |
Comment 6•23 years ago
|
||
> Why?
Using an array of characters rather than a pointer eliminates the need for a
relocation record for each name. Anything that gets relocated is not
necessarily (never?) shared between multiple running instances. Is making it a
fixed width field too much of a hack?
![]() |
||
Updated•23 years ago
|
Attachment #119229 -
Flags: superreview?(alecf)
![]() |
||
Updated•23 years ago
|
Attachment #119224 -
Flags: superreview?(alecf)
![]() |
||
Comment 7•23 years ago
|
||
sorry I haven't gotten to this, I've been focusing more on embedding libraries,
so IMAP fell below the radar. I'll take a look at this ASAP.
Status: UNCONFIRMED → NEW
Ever confirmed: true
![]() |
||
Comment 8•23 years ago
|
||
Comment on attachment 119229 [details] [diff] [review]
More contificationness, this time for addrbook
sr=alecf, getting that easy stuff out of the way :)
Attachment #119229 -
Flags: superreview?(alecf) → superreview+
![]() |
||
Comment 9•23 years ago
|
||
Comment on attachment 119224 [details] [diff] [review]
A patch that constifies some constants
ah, I see what you were trying for, but actually const char name[20] doesn't
really buy you much. there's no extra allocation that goes on here, and you're
actually preventing the linker from re-using these strings. Besides, while
you're saving 4 bytes per string for the pointer to the string, you're wasting
it again in the envelope table because most strings are less than 16 bytes.
I think you can just leave it as const char*, but if you're really desperate,
you should make it
const char* const name;
and that should work.
Attachment #119224 -
Flags: superreview?(alecf) → superreview-
![]() |
||
Comment 11•23 years ago
|
||
oh heh, relocation. In any case, dont' optimize for relocation - if we get
relocated, we're screwed anyway. re-basing the dlls is something that the build
system should do automatically... (though it might not right now, I have no idea)
Comment 12•23 years ago
|
||
Comment on attachment 119229 [details] [diff] [review]
More contificationness, this time for addrbook
r=jst
Attachment #119229 -
Flags: review+
![]() |
Assignee | |
Comment 13•23 years ago
|
||
Here is a new version of the imap patch that gets rid of the offending char
pointer to char array change.
Attachment #119224 -
Attachment is obsolete: true
![]() |
||
Comment 14•23 years ago
|
||
Comment on attachment 119968 [details] [diff] [review]
A patch that constifies some constants, v2
yeah, this works
sr=alecf
thanks for the work! It will be good to see this done on other modules too :)
Attachment #119968 -
Flags: superreview+
![]() |
||
Updated•23 years ago
|
Attachment #119968 -
Flags: review?(bienvenu)
![]() |
||
Comment 15•23 years ago
|
||
Comment on attachment 119229 [details] [diff] [review]
More contificationness, this time for addrbook
Checked in the addressbook patch. Leaving open, since the other patch still
needs review.
![]() |
||
Comment 16•23 years ago
|
||
Comment on attachment 119968 [details] [diff] [review]
A patch that constifies some constants, v2
r=sspitzer, assuming you did some basic smoketest of imap.
Attachment #119968 -
Flags: review?(bienvenu) → review+
![]() |
Assignee | |
Updated•22 years ago
|
Attachment #119229 -
Attachment is obsolete: true
![]() |
Assignee | |
Comment 17•22 years ago
|
||
Comment on attachment 119968 [details] [diff] [review]
A patch that constifies some constants, v2
This patch has been smoke tested; it is ready to check in.
![]() |
||
Comment 18•22 years ago
|
||
Patch checked in.
![]() |
Assignee | |
Comment 19•22 years ago
|
||
This is checked in, marking bug fixed.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
![]() |
||
Comment 20•22 years ago
|
||
This change:
- const char *name;
+ const char * const name;
in nsImapServerResponseParser.cpp got reverted because it broke the win32 build.
The structs in the array are const, so that should be sufficient....
Updated•21 years ago
|
Product: MailNews → Core
Updated•17 years ago
|
Product: Core → MailNews Core
You need to log in
before you can comment on or make changes to this bug.
Description
•