Closed
Bug 1047658
Opened 11 years ago
Closed 11 years ago
Automatically detect nsCharPtrHashKey that could be nsDepCharHashKey
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
INCOMPLETE
People
(Reporter: mccr8, Assigned: mccr8)
Details
(Whiteboard: [MemShrink])
Attachments
(2 files, 1 obsolete file)
nsCharPtrHashKey makes a copy of every string that is passed in to it. nsDepCharHashKey does not. In bug 1047523, froydnj realized that a telemetry hashtable could use the latter instead of the former, saving 38kb of memory.
I think in theory we could hack up a patch that modifies nsCharPtrHashKey to keep around a pointer to the original copy of the string, then checks if the new pointer is the same as the old one in the dtor. You'd want to be careful to only check as far as the length of the new copy, to avoid buffer overflows. If the string is still the same, do an NS_ASSERTION or something to see what table it is from. If this is happening a lot for a particular table, it might be worth investigating if the copies need to be done.
Probably we would not want to land it, or at least would not want it to be on by default.
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → continuation
Assignee | ||
Comment 1•11 years ago
|
||
Assignee | ||
Comment 2•11 years ago
|
||
It looks like there are only a few places that actually use this class, so maybe a direct audit would be a better use of time than digging through weird stack traces.
Assignee | ||
Comment 3•11 years ago
|
||
imgRequest::mProperties is an nsIProperties, which is an nsProperties under the hood. It looks like maybe the only keys used for this are "type" and "content-disposition", but that may be hard to take advantage of without a lot of digging.
Assignee | ||
Comment 4•11 years ago
|
||
This did not produce anything particularly interesting. It pointed out the imgRequest table, probably many of the things are constant strings, and the observer service table. Again, I think in general people pass in static strings to the observer service, so we don't need to copy them, but we really can't depend on that. I measured, and on desktop we're using about 32kb for the observer service. I don't know how much of that is strings.
Attachment #8466487 -
Attachment is obsolete: true
Assignee | ||
Comment 5•11 years ago
|
||
I don't know if this is useful, but here's the basic patch.
Assignee | ||
Comment 6•11 years ago
|
||
There's no reason to keep this open, I think.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → INCOMPLETE
You need to log in
before you can comment on or make changes to this bug.
Description
•