Closed Bug 1249174 Opened 4 years ago Closed 4 years ago

Shrink XPT info some more

Categories

(Core :: XPCOM, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: njn, Assigned: njn)

References

Details

(Whiteboard: [MemShrink:P2])

Attachments

(8 files, 3 obsolete files)

3.50 KB, patch
khuey
: review+
Details | Diff | Splinter Review
2.39 KB, patch
khuey
: review+
Details | Diff | Splinter Review
4.99 KB, patch
khuey
: review+
Details | Diff | Splinter Review
1.52 KB, patch
khuey
: review+
Details | Diff | Splinter Review
8.34 KB, patch
khuey
: review+
Details | Diff | Splinter Review
18.18 KB, patch
khuey
: review+
Details | Diff | Splinter Review
7.31 KB, patch
khuey
: review+
Details | Diff | Splinter Review
5.96 KB, patch
khuey
: review+
Details | Diff | Splinter Review
I have a couple of patches that shrink the size of the XPT info a bit.
PTTypeDescriptor::argnum2 is unused. Removing it reduces
sizeof(XPTTypeDescriptor) from 6 bytes to 4 bytes, which reduces the
"xpti-working-set" measurement by 80 KiB (measured on 64-bit).
Attachment #8720589 - Flags: review?(khuey)
Assignee: nobody → n.nethercote
Status: NEW → ASSIGNED
This reduces "xpti-working-set" by another 16 KiB on 64-bit.
Attachment #8720622 - Flags: review?(khuey)
Removing it reduces the "xpti-working-set" measurement by 16 KiB (measured on
64-bit).
Attachment #8720645 - Flags: review?(khuey)
This requires merging XPT_DoHeaderPrologue() and XPT_DoHeader(), which is
straightforward.

This reduces "xpti-working-set" by 16 KiB on 64-bit platforms.
Attachment #8721075 - Flags: review?(khuey)
With careful layout we can reduce sizeof(XPTTypeDescriptor) from 4 to 3, which
also reduces sizeof(XPTParamDescriptor) from 6 to 4. This reduces
"xpti-working-set" by 16 KiB.

The union-of-structs also improves readability by making it clearer exactly
which fields are used for which types.
Attachment #8721825 - Flags: review?(khuey)
This patch:

- Removes XPTArena's ability to support any alignment.

- Hardwires two sub-arenas into XPTArena, one with alignment of 8 and one with
  alignment of 1.

- Uses the first sub-arena for most allocations and the second sub-arena for C
  string allocations.

These changes reduce "xpti-working-set" by 56 KiB.

The patch also removes the XPT_MALLOC macro in favour of an XPT_CALLOC one, to
make clearer that the result is always zeroed.
Attachment #8721848 - Flags: review?(khuey)
(A tweaked version of the previous patch.)
Attachment #8721860 - Flags: review?(khuey)
Attachment #8721848 - Attachment is obsolete: true
Attachment #8721848 - Flags: review?(khuey)
PTInterfaceDescriptor::num_additional_types can easily fit in 8 bits -- in
practice it doesn't exceed 20, and there's already a check in DoTypeDescriptor
that it doesn't exceed 255. This patch shrinks it and moves that check into
XPT_InterfaceDescriptorAddTypes() so that any overflow would be detected more
reliably.

On 64-bit platforms this reduces sizeof(XPTInterfaceDescriptor) from 40 to 32
and correspondingly reduces "xpti-working-set" by 16 KiB.

The patch also changes XPT_InterfaceDescriptorAddTypes() into a local function,
because it's defined and only used in xpt_struct.cpp.
Attachment #8721871 - Flags: review?(khuey)
The eight patches reduce "xpti-working-set" (on 64-bit platforms) from 1184 KiB to 968 KiB -- a reduction of 216 KiB -- and I'm out of ideas for now.
(I tweaked a comment.)
Attachment #8722094 - Flags: review?(khuey)
Attachment #8721075 - Attachment is obsolete: true
Attachment #8721075 - Flags: review?(khuey)
(I tweaked a comment.)
Attachment #8722095 - Flags: review?(khuey)
Attachment #8721871 - Attachment is obsolete: true
Attachment #8721871 - Flags: review?(khuey)
(In reply to Nicholas Nethercote [:njn] from comment #10)
> The eight patches reduce "xpti-working-set" (on 64-bit platforms) from 1184
> KiB to 968 KiB -- a reduction of 216 KiB -- and I'm out of ideas for now.

I measured on 32-bit as well: 936 KiB drops to 776 KiB, a 160 KiB reduction.
Whiteboard: [MemShrink] → [MemShrink:P2]
https://hg.mozilla.org/integration/mozilla-inbound/rev/fa81f18d5093d47064913e1e7fb6c54d03419df0
Bug 1249174 (part 7) - Only define XPTArena::name if XPT_ARENA_LOGGING is defined. r=khuey.
(In reply to Nicholas Nethercote [:njn] from comment #14)
> https://hg.mozilla.org/integration/mozilla-inbound/rev/
> fa81f18d5093d47064913e1e7fb6c54d03419df0
> Bug 1249174 (part 7) - Only define XPTArena::name if XPT_ARENA_LOGGING is
> defined. r=khuey.

Whoops. That was meant to be part of bug 1248534, which blocks this one, but I got the bug number wrong. No matter, I'll rename the part 7 above ("Avoid wasted space around XPT strings") to 7.5 to avoid further confusion.
https://hg.mozilla.org/mozilla-central/rev/fa81f18d5093
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
More patches to land here.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
You need to log in before you can comment on or make changes to this bug.