[libcxx-commits] [PATCH] D153991: [libc++] explicitly specialises `unique_ptr` when using `default_delete`
Christopher Di Bella via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 28 10:44:37 PDT 2023
cjdb created this revision.
cjdb added reviewers: EricWF, ldionne.
Herald added a project: All.
cjdb requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
`default_delete` is a fairly heavy way to say `delete ptr` or `delete[]
ptr`, so this commit removes invoking the deleter at all. When using the
unstable ABI, we optimise a little further, by making `default_delete` a
static data member, which means that there's exactly one instance per
program for each `unique_ptr<T>`, as opposed to one instance per object.
When I built a debug Clang with the status quo, the stable change, and
the unstable change, I noticed that there was a total ~1% size
reduction. Here's what bloaty records:
**Status quo vs ABI stable change**
FILE SIZE VM SIZE
-------------- --------------
+0.5% +32.1Ki [ = ] 0 .debug_abbrev
[ = ] 0 +0.0% +48 .bss
[NEW] +28 [ = ] 0 [Unmapped]
-2.0% -4 [ = ] 0 .debug_aranges
-0.0% -896 -0.0% -896 .rodata
-1.1% -143Ki [ = ] 0 .debug_rnglists
-1.8% -147Ki -1.8% -147Ki .eh_frame_hdr
-0.9% -296Ki [ = ] 0 .debug_addr
-0.5% -328Ki [ = ] 0 .debug_str_offsets
-1.7% -442Ki [ = ] 0 .symtab
-1.8% -590Ki -1.8% -590Ki .eh_frame
-0.5% -738Ki -0.5% -738Ki .text
-0.7% -1.18Mi [ = ] 0 .debug_line
-1.8% -2.34Mi [ = ] 0 .strtab
-0.9% -3.81Mi [ = ] 0 .debug_info
-1.4% -3.82Mi [ = ] 0 .debug_str
-1.0% -13.7Mi -0.6% -1.44Mi TOTAL
ABI stable smaller.
**Status quo vs ABI unstable change**
FILE SIZE VM SIZE
-------------- --------------
+0.6% +41.7Ki [ = ] 0 .debug_abbrev
+0.0% +448 +0.0% +448 .dynstr
+0.0% +120 +0.0% +120 .dynsym
[ = ] 0 +0.0% +32 .bss
[NEW] +28 [ = ] 0 [Unmapped]
+0.0% +24 +0.0% +24 .gnu.hash
+0.0% +12 +0.0% +12 .gnu.version
+1.0% +4 +1.0% +4 [1 Others]
-3.5% -7 [ = ] 0 .debug_aranges
-57.1% -32 -57.1% -32 [LOAD #2 [R]]
-1.1% -143Ki [ = ] 0 .debug_rnglists
-1.8% -147Ki -1.8% -147Ki .eh_frame_hdr
-0.9% -296Ki [ = ] 0 .debug_addr
-0.5% -337Ki [ = ] 0 .debug_str_offsets
-1.7% -442Ki [ = ] 0 .symtab
-1.8% -589Ki -1.8% -589Ki .eh_frame
-0.5% -747Ki -0.5% -747Ki .text
-0.7% -1.18Mi [ = ] 0 .debug_line
-1.8% -2.34Mi [ = ] 0 .strtab
-1.5% -3.90Mi [ = ] 0 .debug_str
-1.0% -3.92Mi [ = ] 0 .debug_info
-1.0% -13.9Mi -0.6% -1.45Mi TOTAL
ABI unstable smaller.
**Stable vs unstable**
FILE SIZE VM SIZE
-------------- --------------
+0.0% +108Ki [ = ] 0 .debug_info
+0.0% +86.0Ki [ = ] 0 .debug_str
+0.0% +8.98Ki +0.0% +8.98Ki .text
+0.0% +8.75Ki [ = ] 0 .debug_str_offsets
+0.0% +558 [ = ] 0 .debug_line
+133% +32 +133% +32 [LOAD #2 [R]]
+0.0% +28 [ = ] 0 .debug_rnglists
[ = ] 0 +0.0% +16 .bss
+1.6% +3 [ = ] 0 [1 Others]
-1.0% -4 -1.0% -4 .gnu.version_r
-0.0% -12 -0.0% -12 .gnu.version
-0.0% -24 -0.0% -24 .gnu.hash
-0.0% -64 [ = ] 0 .debug_addr
-0.0% -64 -0.0% -64 .eh_frame_hdr
-0.0% -120 -0.0% -120 .dynsym
-0.0% -256 -0.0% -256 .eh_frame
-0.0% -312 [ = ] 0 .symtab
-0.0% -448 -0.0% -448 .dynstr
-0.0% -896 -0.0% -896 .rodata
-0.0% -1.09Ki [ = ] 0 .strtab
-0.1% -9.55Ki [ = ] 0 .debug_abbrev
+0.0% +200Ki +0.0% +7.25Ki TOTAL
ABI unstable smaller.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153991
Files:
libcxx/include/__config
libcxx/include/__memory/unique_ptr.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153991.535465.patch
Type: text/x-patch
Size: 9714 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230628/2ef7790e/attachment-0001.bin>
More information about the libcxx-commits
mailing list