diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-02-28 14:34:33 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-04-03 09:11:03 -0700 |
commit | d41b7648558757dbfd0958335dba1406be60fb4f (patch) | |
tree | 7e2c9a18524dda7ff7403c4568735770a3035708 /bfd/libbfd-in.h | |
parent | c6291d749aece753ae8dcba0a5baff2fe9598541 (diff) | |
download | gdb-d41b7648558757dbfd0958335dba1406be60fb4f.zip gdb-d41b7648558757dbfd0958335dba1406be60fb4f.tar.gz gdb-d41b7648558757dbfd0958335dba1406be60fb4f.tar.bz2 |
elf: Don't cache symbol nor relocation tables with mmap
During a "-j 8" LLVM 17 debug build on a machine with 32GB RAM and 16GB
swap, ld was killed by kernel because of out of memory:
[79437.949336] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/session-9.scope,task=ld,pid=797431,uid=1000
[79437.949349] Out of memory: Killed process 797431 (ld) total-vm:9219600kB, anon-rss:6558156kB, file-rss:1792kB, shmem-rss:0kB, UID:1000 pgtables:17552kB oom_score_adj:0
Don't cache symbol nor relocation tables if they are mapped in. Data to
link the 3.5GB clang executable in LLVM 17 debug build on Linux/x86-64
with 32GB RAM is:
stdio mmap improvement
user 86.73 87.02 -0.3%
system 9.55 9.21 3.6%
total 100.40 97.66 0.7%
maximum set(GB) 17.34 13.14 24%
page faults 4047667 3042877 25%
and data to link the 275M cc1plus executable in GCC 14 stage 1 build is:
user 5.41 5.44 -0.5%
system 0.80 0.76 5%
total 6.25 6.26 -0.2%
maximum set(MB) 1323 968 27%
page faults 323451 236371 27%
These improve the overall system performance for parallel build by
reducing memory usage and page faults.
Also rename _bfd_link_keep_memory to _bfd_elf_link_keep_memory. Since
the --no-keep-memory linker option causes:
https://sourceware.org/bugzilla/show_bug.cgi?id=31458
this is opt-in by each backend.
bfd/
* elf32-i386.c (elf_i386_scan_relocs): Remove
_bfd_link_keep_memory.
* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
* elflink.c (_bfd_elf_link_keep_memory): New.
(_bfd_elf_link_iterate_on_relocs): Replace _bfd_link_keep_memory
with _bfd_elf_link_keep_memory.
(elf_link_add_object_symbols): Likewise.
(init_reloc_cookie): Likewise.
(init_reloc_cookie_rels): Likewise.
* libbfd-in.h (_bfd_link_keep_memory): Removed.
* linker.c (_bfd_link_keep_memory): Likewise.
* libbfd.h: Regenerated.
Diffstat (limited to 'bfd/libbfd-in.h')
-rw-r--r-- | bfd/libbfd-in.h | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index 889b221..7bfc58f 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -848,9 +848,6 @@ extern bfd_byte * _bfd_write_unsigned_leb128 extern struct bfd_link_info *_bfd_get_link_info (bfd *) ATTRIBUTE_HIDDEN; -extern bool _bfd_link_keep_memory (struct bfd_link_info *) - ATTRIBUTE_HIDDEN; - extern uintptr_t _bfd_pagesize ATTRIBUTE_HIDDEN; extern uintptr_t _bfd_pagesize_m1 ATTRIBUTE_HIDDEN; extern uintptr_t _bfd_minimum_mmap_size ATTRIBUTE_HIDDEN; |