Closed Bug 1441255 Opened 6 years ago Closed 6 years ago

Don't make an extra copy of the name string in xptiInterfaceEntry

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla60
Tracking Status
firefox60 --- fixed

People

(Reporter: mccr8, Assigned: mccr8)

Details

Attachments

(2 files)

xptiInterfaceEntry::Create() gets passed in a string for the name of the interface, which it then copies and stores inline at the end of the object (!!!). Presumably this is to guard against the string argument going away before the entry does. However, both the string and the entry are allocated in gXPTIStructArena, so that is not possible. Avoiding the copy will reduce the amount of memory needed for the XPT info. This was added in bug 114115, but I don't see any explanation for why it is done this way. This will make locality worse when accessing the name field, but I can't imagine that matters.

This reduces xpti-working-set from 0.85MB to 0.84MB, so not much of an improvement.
Comment on attachment 8954129 [details]
Bug 1441255, part 1 - Fix argument names for xptiInterfaceEntry creation.

https://reviewboard.mozilla.org/r/223274/#review229410
Attachment #8954129 - Flags: review?(n.nethercote) → review+
Comment on attachment 8954130 [details]
Bug 1441255, part 2 - Don't make an extra copy of the name string in xptiInterfaceEntry.

https://reviewboard.mozilla.org/r/223276/#review229414

The average name length is probably only slightly more than 8, in which case the pointer isn't much better than the inline string. But it's still good to remove an instance of the variable-length struct hack.
Attachment #8954130 - Flags: review?(n.nethercote) → review+
Good point. Yeah, my main motivation was making this code less scary.
Pushed by amccreight@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/58b89afdcd14
part 1 - Fix argument names for xptiInterfaceEntry creation. r=njn
https://hg.mozilla.org/integration/autoland/rev/16f0fd2f5455
part 2 - Don't make an extra copy of the name string in xptiInterfaceEntry. r=njn
https://hg.mozilla.org/mozilla-central/rev/58b89afdcd14
https://hg.mozilla.org/mozilla-central/rev/16f0fd2f5455
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: