Closed
Bug 927078
Opened 12 years ago
Closed 12 years ago
Don't copy string data when sending messages using message manager
Categories
(Core :: IPC, defect)
Core
IPC
Tracking
()
| Tracking | Status | |
|---|---|---|
| b2g-v1.3T | --- | fixed |
People
(Reporter: smaug, Assigned: smaug)
References
Details
Attachments
(2 files, 1 obsolete file)
|
7.31 KB,
patch
|
benjamin
:
review+
dbaron
:
superreview-
|
Details | Diff | Splinter Review |
|
3.52 KB,
patch
|
benjamin
:
review+
|
Details | Diff | Splinter Review |
We could just improve nsDependentString a bit and use it to pass data
to IPC layer.
Patch coming.
| Assignee | ||
Comment 1•12 years ago
|
||
nsDependentString is a bit error prone, but the patch doesn't make it any
worse. Requirement to pass null-terminated string to it is left to the caller anyway.
(And need to fix the name AssertValidDepedentString at some point, but not in this bug)
Attachment #817431 -
Flags: review?(benjamin)
Comment 2•12 years ago
|
||
Comment on attachment 817431 [details] [diff] [review]
patch
The constructor seems like a footgun for future generations.
Could we make the callsites intentionally uglier so that instead of nsDependentString(aMessage) its nsDependentString(aMessage.BeginReading(), aMessage.Length()) ?
But also more generally, how do you know that aMessage (in ChildProcessMessageManagerCallback::DoSendBlockingMessage) actually is null-terminated? I don't see any external guarantees of that.
| Assignee | ||
Comment 3•12 years ago
|
||
(In reply to Benjamin Smedberg [:bsmedberg] from comment #2)
> The constructor seems like a footgun for future generations.
Not more than our current nsDependentString ctors
>
> But also more generally, how do you know that aMessage (in
> ChildProcessMessageManagerCallback::DoSendBlockingMessage) actually is
> null-terminated? I don't see any external guarantees of that.
Well, we get null-terminated strings from JS. and MM is JS-only API.
I could do something uglier but safer - basically check whether the string is null terminated and only
then use DependentString and otherwise copy data.
| Assignee | ||
Updated•12 years ago
|
Attachment #817431 -
Flags: review?(benjamin)
Comment 4•12 years ago
|
||
Hi Olli, we're looking for any little wins we can get for tarako. Any time to finish this up?
Flags: needinfo?(bugs)
| Assignee | ||
Comment 5•12 years ago
|
||
/me doesn't know what tarako is.
| Assignee | ||
Comment 6•12 years ago
|
||
But sure, I could take a look at this again.
Flags: needinfo?(bugs)
Comment 7•12 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #5)
> /me doesn't know what tarako is.
It's a FxOS device with 128MiB of RAM, so it's a platform where every bit counts (literally).
See the wiki page for more info https://wiki.mozilla.org/FirefoxOS/Tarako
| Assignee | ||
Comment 8•12 years ago
|
||
Something like this then. Safer, and removes still lots of extra copying.
https://tbpl.mozilla.org/?tree=Try&rev=8bfa74513f7f
Attachment #817431 -
Attachment is obsolete: true
Attachment #8375896 -
Flags: review?(benjamin)
Updated•12 years ago
|
Whiteboard: [tarako]
Comment 9•12 years ago
|
||
Comment on attachment 8375896 [details] [diff] [review]
maybedependentstring.diff
r=me but I'd like dbaron to review the API as well.
Attachment #8375896 -
Flags: superreview?(dbaron)
Attachment #8375896 -
Flags: review?(benjamin)
Attachment #8375896 -
Flags: review+
| Assignee | ||
Updated•12 years ago
|
Attachment #8375896 -
Flags: superreview?(dbaron)
| Assignee | ||
Updated•12 years ago
|
Attachment #8375896 -
Flags: superreview?(dbaron)
How is this different from the existing PromiseFlat[C]String functions, which use the nsPromiseFlat[C]String class?
Flags: needinfo?(bugs)
(We should probably rename those from PromiseFlat to PromiseTerminated, given that we no longer have multi-fragment strings. Flat is the name we used meaning both single-fragment and terminated.)
Comment on attachment 8375896 [details] [diff] [review]
maybedependentstring.diff
I don't see any difference between this and PromiseFlatString; I think you should just use that.
Attachment #8375896 -
Flags: superreview?(dbaron) → superreview-
| Assignee | ||
Comment 13•12 years ago
|
||
Crap, we have two kinds of PromiseFlatStrings. One which is useful, and one in glue which is just
typedef from nsString. And I was aware of only the latter. I didn't know PromiseFlatStrings had this kind of odd side effect.
| Assignee | ||
Comment 14•12 years ago
|
||
(We should not have inconsistent APIs. glue exposing totally different API behavior with the same name is horrible.)
Flags: needinfo?(bugs)
Comment 15•12 years ago
|
||
The glue version does in fact promise a flat string. It just always performs a share or a copy instead of sometimes doing a dependent string, because the glue API isn't aware of the flags for that. And it was necessary to add this to the glue to compile mailnews in some configurations.
| Assignee | ||
Comment 16•12 years ago
|
||
Attachment #8379705 -
Flags: review?(benjamin)
Updated•12 years ago
|
Attachment #8379705 -
Flags: review?(benjamin) → review+
| Assignee | ||
Comment 17•12 years ago
|
||
Comment 18•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
Updated•12 years ago
|
blocking-b2g: --- → 1.3T?
Whiteboard: [tarako]
Comment 19•12 years ago
|
||
Hi Olli, I wonder if we know how much memory saving this patch can provide? trying to evaluate if this is needed for Tarako project (128MB RAM Firefox OS project). thanks
Flags: needinfo?(bugs)
| Assignee | ||
Comment 20•12 years ago
|
||
This is more performance win than memory saving.
Well, it reduces memory usage too, but that just a short amount memory during a very short period.
Flags: needinfo?(bugs)
Updated•12 years ago
|
blocking-b2g: 1.3T? → 1.3T+
Comment 21•12 years ago
|
||
status-b2g-v1.3T:
--- → fixed
You need to log in
before you can comment on or make changes to this bug.
Description
•