Pay as you go is really going to make a difference

Gregor Mückl gregormueckl at gmx.de
Fri Jan 24 22:20:45 UTC 2020


On Friday, 24 January 2020 at 09:52:13 UTC, Johan Engelen wrote:
> Indeed. Also to figure out why LDC's binary calls 31 more than 
> DMD's binary.
> Much appreciated if someone could repeat the test and post a 
> list of all syscalls being made.
>
> -Johan

Here is a run of a statically linked hello world binary on Linux:

execve("./hello", ["./hello"], 0x7fffd9d9d0e0 /* 15 vars */) = 0
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffff1a05c70) = -1 EINVAL 
(Invalid argument)
brk(NULL)                               = 0x1364000
brk(0x1365340)                          = 0x1365340
arch_prctl(ARCH_SET_FS, 0x1364a00)      = 0
uname({sysname="Linux", nodename="kangoroo", ...}) = 0
set_tid_address(0x1364cd0)              = 111
set_robust_list(0x1364ce0, 24)          = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x453cb0, sa_mask=[], 
sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x4531b0}, NULL, 8) 
= 0
rt_sigaction(SIGRT_1, {sa_handler=0x453d50, sa_mask=[], 
sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, 
sa_restorer=0x4531b0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, 
rlim_max=8192*1024}) = 0
readlink("/proc/self/exe", "/root/hello", 4096) = 11
brk(0x1386340)                          = 0x1386340
brk(0x1387000)                          = 0x1387000
clock_getres(CLOCK_MONOTONIC, {tv_sec=0, tv_nsec=100}) = 0
clock_getres(CLOCK_BOOTTIME, {tv_sec=0, tv_nsec=100}) = 0
clock_getres(CLOCK_MONOTONIC_COARSE, {tv_sec=0, tv_nsec=100}) = 0
clock_getres(CLOCK_MONOTONIC, {tv_sec=0, tv_nsec=100}) = 0
clock_getres(CLOCK_PROCESS_CPUTIME_ID, {tv_sec=0, 
tv_nsec=15625000}) = 0
clock_getres(CLOCK_MONOTONIC_RAW, {tv_sec=0, tv_nsec=100}) = 0
clock_getres(CLOCK_THREAD_CPUTIME_ID, {tv_sec=0, 
tv_nsec=15625000}) = 0
rt_sigaction(SIGUSR1, {sa_handler=0x42ac20, sa_mask=~[RTMIN 
RT_1], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x4531b0}, 
NULL, 8) = 0
rt_sigaction(SIGUSR2, {sa_handler=0x42ad20, sa_mask=~[RTMIN 
RT_1], sa_flags=SA_RESTORER, sa_restorer=0x4531b0}, NULL, 8) = 0
openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_CLOEXEC) = 3
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, 
rlim_max=8192*1024}) = 0
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "00400000-00561000 r-xp 00000000 "..., 4096) = 488
close(3)                                = 0
brk(0x1386000)                          = 0x1386000
sched_getaffinity(111, 32, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
11]) = 32
clock_getres(CLOCK_MONOTONIC, {tv_sec=0, tv_nsec=100}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=469, tv_nsec=741732400}) = 
0
rt_sigaction(SIGSEGV, {sa_handler=0x4402b0, sa_mask=~[RTMIN 
RT_1], sa_flags=SA_RESTORER|SA_RESETHAND|SA_SIGINFO, 
sa_restorer=0x4531b0}, {sa_handler=SIG_DFL, sa_mask=[], 
sa_flags=SA_RESTORER, sa_restorer=0x7fa7e7f94fb0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0x4402b0, sa_mask=~[RTMIN RT_1], 
sa_flags=SA_RESTORER|SA_RESETHAND|SA_SIGINFO, 
sa_restorer=0x4531b0}, {sa_handler=SIG_DFL, sa_mask=[], 
sa_flags=SA_RESTORER, sa_restorer=0x7fa7e7f94fb0}, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=SIG_DFL, sa_mask=[], 
sa_flags=SA_RESTORER, sa_restorer=0x4531b0}, NULL, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=SIG_DFL, sa_mask=[], 
sa_flags=SA_RESTORER, sa_restorer=0x4531b0}, NULL, 8) = 0
fstat(1, {st_mode=S_IFCHR|0660, st_rdev=makedev(0x4, 0x1), ...}) 
= 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "hello world\n", 12)           = 12
write(1, "\n", 1)                       = 1
exit_group(0)                           = ?
+++ exited with 0 +++

I linked it statically to exclude the huge number of system calls 
made by ld.so. There's little that could be done to improve on 
those, I think.

If I let strace dump stack traces for each call, the first 
mention of druntime is after the two consecutive brk calls. But 
I'm not sure if the traces are trustworthy. They seem cut short 
in a couple of instances.

So there's a couple of calls that should be fairly fast 
(clock_getres etc.). Why does the runtime need to read 
/proc/self/maps, though?


More information about the Digitalmars-d mailing list