3 ms·
I strace'd Rust's hello world and the vast majority of the syscalls are just ld.so setting up dynamically loaded libraries. Presumably if you really cared you c
by pcwalton 7y ago
I strace'd Rust's hello world and the vast majority of the syscalls are just ld.so setting up dynamically loaded libraries. Presumably if you really cared you could statically link against musl to eliminate those. The remaining syscalls are needed for stack guards to work, which you actually want for security, even with hello world.
I would go so far as to say that publishing benchmarks that encourages languages to skimp on important security features like guard pages is irresponsible.
- glandium 7y agoIt's still weird that it has significantly more syscalls than the C program dynamically linked to glibc, which presumably has the same overhead wrt ld.so and guard pages. (BTW, the guard page for the main thread, IIRC, is setup by the kernel)
- pcwalton 7y agoHere are the list of syscalls: https://gist.github.com/pcwalton/60ff97c2353feda11638be10118851f2 https://gist.github.com/pcwalton/60ff97c2353feda11638be10118... I think the extra syscalls you're referring to are the result of linking with pthread. Obviously Rust code always wants thread support. Here's the setup code: https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/thread.rs https://github.com/rust-lang/rust/blob/master/src/libstd/sys... A fair number of the syscalls are to ensure that stack overflow is reported like a Rust panic (with a stack trace), not like a segv in unsafe code. I think this is worth it.