Closed Bug 200389 Opened 23 years ago Closed 22 years ago

better constness in mailnews/imap

Categories

(MailNews Core :: Networking: IMAP, defect)

defect
Not set
trivial

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ataylor, Assigned: ataylor)

Details

(Keywords: memory-footprint)

Attachments

(1 file, 2 obsolete files)

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:
Keywords: footprint
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.
Another patch that does the same for mailnews/addrbook.
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.
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?
> 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?
Attachment #119229 - Flags: superreview?(alecf)
Attachment #119224 - Flags: superreview?(alecf)
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 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 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-
andrew over to you, since you're fixing this!
Assignee: bienvenu → ataylor
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 on attachment 119229 [details] [diff] [review] More contificationness, this time for addrbook r=jst
Attachment #119229 - Flags: review+
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 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+
Attachment #119968 - Flags: review?(bienvenu)
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 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+
Attachment #119229 - Attachment is obsolete: true
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.
Patch checked in.
This is checked in, marking bug fixed.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
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....
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: