Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # let's have a look at all the processes running on the system...
- [ armitage watchtower straylight dev ~/src/uv/straylight ] l /proc/*/exe 2>/dev/null
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/100/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/1013/exe
- ... omitted ...
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/136896/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/137723/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/13/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/140655/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/141922/exe
- lrwxrwxrwx 0 armitage 14 Aug 02:20 /proc/1426/exe -> /nix/store/lwkp9z6w20yvavz6g87gfiglbp5xagb0-systemd-250.4/lib/systemd/systemd
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/1427/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/144318/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/145674/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/145980/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/145/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/146/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/147928/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/147/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/148449/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/14/exe
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/1504/exe -> /nix/store/vkgkg1cz4ny46n9wqy0cb0y618m22y0a-tmux-3.2a/bin/tmux
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/1546/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/155/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/156/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/159634/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/15/exe
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/16262/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/163292/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/166990/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/16/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/170678/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/174321/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/177989/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/17/exe
- lrwxrwxrwx 0 armitage 14 Aug 16:52 /proc/181296/exe -> /nix/store/vix7lkybm9m9l0sjipcpxhnpgkgwqpvk-openjdk-headless-11.0.15+10/lib/openjdk/bin/java
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/183118/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/18/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/193045/exe
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/193050/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/193068/exe -> /nix/store/vkgkg1cz4ny46n9wqy0cb0y618m22y0a-tmux-3.2a/bin/tmux
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/19/exe
- lrwxrwxrwx 0 root 14 Aug 01:16 /proc/1/exe
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/202571/exe -> /nix/store/887536bk4zhcirg95ynhqr9klkfnm0z8-emacs-28.1/bin/.emacs-28.1-wrapped
- lrwxrwxrwx 0 armitage 14 Aug 17:08 /proc/202586/exe -> /nix/store/cl3hvqmapznjsw06l5hyfnjnhbhknbcd-haskell-language-server-1.7.0.0/bin/haskell-language-server
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/204033/exe
- lrwxrwxrwx 0 armitage 14 Aug 17:29 /proc/204604/exe -> /nix/store/csvwymvk2pgdkawlc1x75gz3rci7z1as-clang-13.0.1/bin/clangd
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/205467/exe
- lrwxrwxrwx 0 root 14 Aug 17:55 /proc/206407/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/206/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/96/exe
- ... ommitted ...
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/976/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/97/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/98/exe
- lrwxrwxrwx 0 root 14 Aug 17:54 /proc/99/exe
- lrwxrwxrwx 0 armitage 14 Aug 18:03 /proc/self/exe -> /nix/store/rdqp622ff9ssyhgjv375ah3bvp45nizp-exa-0.10.1/bin/exa
- lrwxrwxrwx 0 armitage 14 Aug 18:03 /proc/thread-self/exe -> /nix/store/rdqp622ff9ssyhgjv375ah3bvp45nizp-exa-0.10.1/bin/exa
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # we only want the ones where the `exe` symlink points somewhere, the rest are (mostly) internal kernel processes (e.g. `[ksoftirqd/2]`)
- [ armitage watchtower straylight dev ~/src/uv/straylight ] l /proc/*/exe 2>/dev/null | rg ">"
- lrwxrwxrwx 0 armitage 14 Aug 02:20 /proc/1426/exe -> /nix/store/lwkp9z6w20yvavz6g87gfiglbp5xagb0-systemd-250.4/lib/systemd/systemd
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/1504/exe -> /nix/store/vkgkg1cz4ny46n9wqy0cb0y618m22y0a-tmux-3.2a/bin/tmux
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/1546/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/16262/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 armitage 14 Aug 16:52 /proc/181296/exe -> /nix/store/vix7lkybm9m9l0sjipcpxhnpgkgwqpvk-openjdk-headless-11.0.15+10/lib/openjdk/bin/java
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/193050/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/193068/exe -> /nix/store/vkgkg1cz4ny46n9wqy0cb0y618m22y0a-tmux-3.2a/bin/tmux
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/202571/exe -> /nix/store/887536bk4zhcirg95ynhqr9klkfnm0z8-emacs-28.1/bin/.emacs-28.1-wrapped
- lrwxrwxrwx 0 armitage 14 Aug 17:08 /proc/202586/exe -> /nix/store/cl3hvqmapznjsw06l5hyfnjnhbhknbcd-haskell-language-server-1.7.0.0/bin/haskell-language-server
- lrwxrwxrwx 0 armitage 14 Aug 17:29 /proc/204604/exe -> /nix/store/csvwymvk2pgdkawlc1x75gz3rci7z1as-clang-13.0.1/bin/clangd
- lrwxrwxrwx 0 armitage 14 Aug 18:06 /proc/207784/exe -> /nix/store/rdqp622ff9ssyhgjv375ah3bvp45nizp-exa-0.10.1/bin/exa
- lrwxrwxrwx 0 armitage 14 Aug 18:06 /proc/207785/exe -> /nix/store/y1ilfhl51jr1m8y8dn2pl07703ppcadn-ripgrep-13.0.0/bin/rg
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/3828/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/3907/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/47099/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 armitage 14 Aug 17:54 /proc/61232/exe -> /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- lrwxrwxrwx 0 armitage 14 Aug 18:06 /proc/self/exe -> /nix/store/rdqp622ff9ssyhgjv375ah3bvp45nizp-exa-0.10.1/bin/exa
- lrwxrwxrwx 0 armitage 14 Aug 18:06 /proc/thread-self/exe -> /nix/store/rdqp622ff9ssyhgjv375ah3bvp45nizp-exa-0.10.1/bin/exa
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # let's get the unique ones
- [ armitage watchtower straylight dev ~/src/uv/straylight ] l /proc/*/exe 2>/dev/null | rg ">" | awk -F " " '{ print $NF }' | sort | uniq -c
- 2 /nix/store/47n5hzqpahs7yv84ia6cxp3jg9ca8r86-coreutils-9.0/bin/coreutils
- 1 /nix/store/887536bk4zhcirg95ynhqr9klkfnm0z8-emacs-28.1/bin/.emacs-28.1-wrapped
- 1 /nix/store/cl3hvqmapznjsw06l5hyfnjnhbhknbcd-haskell-language-server-1.7.0.0/bin/haskell-language-server
- 1 /nix/store/csvwymvk2pgdkawlc1x75gz3rci7z1as-clang-13.0.1/bin/clangd
- 1 /nix/store/fr7vrxblkj327ypn3vhjwfhf19lddqqd-gawk-5.1.1/bin/gawk
- 1 /nix/store/lwkp9z6w20yvavz6g87gfiglbp5xagb0-systemd-250.4/lib/systemd/systemd
- 7 /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash
- 3 /nix/store/rdqp622ff9ssyhgjv375ah3bvp45nizp-exa-0.10.1/bin/exa
- 1 /nix/store/vix7lkybm9m9l0sjipcpxhnpgkgwqpvk-openjdk-headless-11.0.15+10/lib/openjdk/bin/java
- 2 /nix/store/vkgkg1cz4ny46n9wqy0cb0y618m22y0a-tmux-3.2a/bin/tmux
- 1 /nix/store/y1ilfhl51jr1m8y8dn2pl07703ppcadn-ripgrep-13.0.0/bin/rg
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # roughly 21 processes
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # let's have a look at the dynamic linking story for just `glibc` (that's the red meat)...
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # we'll start with one of my programs (links in a bunch of stuff! but i know about static linking...)
- [ armitage watchtower straylight dev ~/src/uv/straylight ] readelf -d generated/cpp/simd/tests/x86_tests
- Dynamic section at offset 0x1f6258 contains 32 entries:
- Tag Type Name/Value
- 0x0000000000000003 (PLTGOT) 0x5f7aa8
- 0x0000000000000002 (PLTRELSZ) 4008 (bytes)
- 0x0000000000000017 (JMPREL) 0x404160
- 0x0000000000000014 (PLTREL) RELA
- 0x0000000000000007 (RELA) 0x4040d0
- 0x0000000000000008 (RELASZ) 144 (bytes)
- 0x0000000000000009 (RELAENT) 24 (bytes)
- 0x0000000000000015 (DEBUG) 0x0
- 0x0000000000000006 (SYMTAB) 0x400360
- 0x000000000000000b (SYMENT) 24 (bytes)
- 0x0000000000000005 (STRTAB) 0x401dd0
- 0x000000000000000a (STRSZ) 7087 (bytes)
- 0x000000006ffffef5 (GNU_HASH) 0x403980
- 0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
- 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0]
- 0x0000000000000001 (NEEDED) Shared library: [libdl.so.2]
- 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
- 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
- 0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2]
- 0x000000000000000c (INIT) 0x405108
- 0x000000000000000d (FINI) 0x578530
- 0x000000000000001a (FINI_ARRAY) 0x5eaba0
- 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
- 0x0000000000000019 (INIT_ARRAY) 0x5eaba8
- 0x000000000000001b (INIT_ARRAYSZ) 88 (bytes)
- 0x000000000000001d (RUNPATH) Library runpath: [/nix/store/lyl6nysc3i3aqhj6shizjgj0ibnf1pvg-glibc-2.34-210/lib]
- 0x000000000000001e (FLAGS) BIND_NOW
- 0x000000006ffffffb (FLAGS_1) NOW
- 0x000000006ffffff0 (VERSYM) 0x403d4c
- 0x000000006ffffffe (VERNEED) 0x403f80
- 0x000000006fffffff (VERNEEDNUM) 4
- 0x0000000000000000 (NULL) 0x0
- [ armitage watchtower straylight dev ~/src/uv/straylight ] l /nix/store/lyl6nysc3i3aqhj6shizjgj0ibnf1pvg-glibc-2.34-210/lib | rg "(libpthread.so.0|libm.so.6|libdl.so.2|libgcc_s.so.1|libc.so.6|ld-linux-x86-64.so.2)"
- .r-xr-xr-x 228k root 1 Jan 1970 ld-linux-x86-64.so.2
- .r-xr-xr-x 2.4M root 1 Jan 1970 libc.so.6
- lrwxrwxrwx 10 root 1 Jan 1970 libdl.so -> libdl.so.2
- .r-xr-xr-x 16k root 1 Jan 1970 libdl.so.2
- .r--r--r-- 112k root 1 Jan 1970 libgcc_s.so.1
- .r-xr-xr-x 967k root 1 Jan 1970 libm.so.6
- lrwxrwxrwx 15 root 1 Jan 1970 libpthread.so -> libpthread.so.0
- .r-xr-xr-x 16k root 1 Jan 1970 libpthread.so.0
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # so our upper limit on savings is like, 4mb * 20 processes (the 21st means we had to have it no matter what), or 80Mb
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # let's have a look at the dynamic linking story...
- [ armitage watchtower straylight dev ~/src/uv/straylight ] nm -gu ./generated/cpp/simd/tests/x86_tests
- w _ITM_RU1
- w _ITM_RU8
- w _ITM_addUserCommitAction
- w _ITM_deregisterTMCloneTable
- w _ITM_memcpyRnWt
- w _ITM_memcpyRtWn
- w _ITM_registerTMCloneTable
- U _Unwind_DeleteException
- U _Unwind_GetDataRelBase
- U _Unwind_GetIPInfo
- U _Unwind_GetLanguageSpecificData
- U _Unwind_GetRegionStart
- U _Unwind_GetTextRelBase
- U _Unwind_RaiseException
- U _Unwind_Resume
- U _Unwind_Resume_or_Rethrow
- U _Unwind_SetGR
- U _Unwind_SetIP
- w _ZGTtdlPv
- w _ZGTtnam
- ... ommitted ...
- U mbsnrtowcs
- U mbsrtowcs
- U memchr
- U memcmp
- U memcpy
- U memmove
- U memset
- U nanosleep
- U nextafter
- U nextafterf
- ... omitted ...
- U wmemcmp
- U wmemcpy
- U wmemmove
- U wmemset
- U write
- U writev
- [ armitage watchtower straylight dev ~/src/uv/straylight ] nm -gu ./generated/cpp/simd/tests/x86_tests | wc -l
- 175
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # 175 symbols brought in by the dynamic linker, that seems kinda low, how many does `glibc` export?
- [ armitage watchtower straylight dev ~/src/uv/straylight ] nm /nix/store/lyl6nysc3i3aqhj6shizjgj0ibnf1pvg-glibc-2.34-210/lib/libc.so.6 | wc -l
- 8207
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # hrm, i'm not using much of that at all...
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # i bet my linker can do a much better job packing that into a small number of `TEXT` pages
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # ok, but that's my program, not going to be many of those running...
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # most of my processes are `bash`, how many does it use ()?
- [ armitage watchtower straylight dev ~/src/uv/straylight ] nm -gu /nix/store/pa9416c0x5qa4r2z3zq701qg8gyr0c73-bash-interactive-5.1-p16/bin/bash | wc -l
- 380
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # ok so even bash is loading like 4mb of `.so` to get 380/8207 symbols, and the kernel shares those across all 7 bash processes...
- [ armitage watchtower straylight dev ~/src/uv/straylight ] # i'm not so sold on this dynamic linking thing...
- [ armitage watchtower straylight dev ~/src/uv/straylight ]
Advertisement
Add Comment
Please, Sign In to add comment