Closed Bug 1087834 Opened 11 years ago Closed 11 years ago

Reduce heap churn involving |input_overflow_buf_|

Categories

(Core :: IPC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: n.nethercote, Assigned: n.nethercote)

References

Details

Attachments

(1 file)

Prior to bug 811596, when a large IPC message was received the input_overflow_buf_ buffer would grow to fit the message. And it would never shrunk, so 99.9% of the time the large buffer would be mostly unused space. So in bug 811596 I added code to shrink the buffer after a message was dealt with. This reduced the size down to 8 KiB, often from 500+ KiB, which is a big deal on B2G. Alas, I just discovered that I did it in a sub-optimal way: because C++ strings don't provide a guaranteed way to shrink a string's capacity, I instead replaced the string's buffer with a new, small one. But my code does this *for every message*. And since most messages are small, that means that most of the time we replace the existing buffer with a new one that is exactly the same size. This causes many unnecessary allocations and lots of heap churn. Whoops.
This patch changes things so that the buffer only gets replaced if it is bigger than the standard (small) size. In some simple e10s-enabled browsing I found this avoids the reallocation in 99.7% of cases.
Attachment #8510013 - Flags: review?(wmccloskey)
Attachment #8510013 - Flags: review?(wmccloskey) → review+
Thank you for the fast review.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: