Closed
Bug 120718
Opened 24 years ago
Closed 24 years ago
XPCReadableJSStringWrapper is too malloc happy.
Categories
(Core :: XPConnect, defect, P2)
Core
XPConnect
Tracking
()
VERIFIED
FIXED
mozilla0.9.9
People
(Reporter: jst, Assigned: jst)
References
Details
(Keywords: perf, Whiteboard: [HAVE FIX])
Attachments
(2 files)
11.05 KB,
patch
|
jag+mozilla
:
superreview+
|
Details | Diff | Splinter Review |
10.68 KB,
patch
|
dbaron
:
review+
jag+mozilla
:
superreview+
|
Details | Diff | Splinter Review |
Every time a string is passed as a DOMString/AString from JS to C++ through
XPConnect and the C++ code touches the string, the string code ends up having to
allocate a buffer handle. The allocations (new's) show up when profiling DOM
code, and these allocations accounts for ~450 of the mallocs we do when starting
mozilla and immediately exiting. I bet these allocations happen quite frequently
while running the browser too. Patch coming up that makes the
XPCReadableJSStringWrapper code only allocate the buffer handle when a shared
handle is requested, not when a non-shared handle is requested. This is done at
the expense of increasing the size of the XPCReadableJSStringWrapper class, but
instances of the XPCReadableJSStringWrapper class are always transient, they're
never held in memory for a long time.
Assignee | ||
Comment 1•24 years ago
|
||
Assignee | ||
Comment 2•24 years ago
|
||
I believe this patch is ready for reviews, anyone wanto have a look?
Status: NEW → ASSIGNED
Keywords: perf
Priority: -- → P2
Whiteboard: [HAVE FIX]
Target Milestone: --- → mozilla0.9.9
Comment 3•24 years ago
|
||
Comment on attachment 65569 [details] [diff] [review]
Don't allocate non-shared buffer handles.
Looks good, sr=jag. I'd appreciate it if dbaron could be the r= since this
builds on his code.
Attachment #65569 -
Flags: superreview+
Comment on attachment 65569 [details] [diff] [review]
Don't allocate non-shared buffer handles.
I did something similar in my work on AtomString that I never finished, and I'd
like to do something similar for nsXPIDL[C]String...
mBufferHandle should just be an nsBufferHandle<PRUnichar> -- why use a 5-word
handle when you can use a 2-word handle?
Perhaps you could rename |GetVoidBufferHandle| to |GetSharedEmptyBufferHandle|
for consistency with other string classes? (Unless you meant it to set the
kIsNULL bit.)
For |GetBufferHandle|, I see no reason that you need the |!mStr| check -- won't
mBufferHandle always be valid?
I think you'll also want to override GetFlatBufferHandle so that calling
PromiseFlatString doesn't lead to the creation of a shared buffer handle -- it
can just call GetBufferHandle.
Assignee | ||
Comment 5•24 years ago
|
||
Thanks dbaron, how about this version? I decided to get rid of
GetVoidBufferHandle() and put the code inline in GetSharedBufferHandle() since
that's the only place it's needed (as you suggested).
Comment on attachment 65678 [details] [diff] [review]
Incorporate dbaron's suggestions
r=dbaron, although I'm not sure why you want to change it from inheriting from
...WithAllocator to ...WithDestroy.
Attachment #65678 -
Flags: review+
Assignee | ||
Comment 7•24 years ago
|
||
Because then I don't need an allocator, if there are clear benefits to using
...WithAllocator over ...WithDestroy then I could switch back, let me know if I
should...
Comment 8•24 years ago
|
||
Comment on attachment 65678 [details] [diff] [review]
Incorporate dbaron's suggestions
sr=jag
Attachment #65678 -
Flags: superreview+
Assignee | ||
Comment 9•24 years ago
|
||
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•