How many kernel system calls does Rust make?

preview_player
Показать описание
If you want to know how many kernel system calls Rust makes, then this video is for you. Dive into the world of Rust programming and Linux system calls to expand your knowledge!

#rustlang #linux
Рекомендации по теме
Комментарии
Автор

very interesting, thanks for doing rust! I wouldn’t have guessed what it was doing extra.

now you are making me wonder what if we wrote the code without using the stdio library (which is just a wrapper to system calls) and did the system calls directly..

hnasr
Автор

Forgetting to free memory during a crash does not leak it, the operating system clears it up. However Rust does try to enforce the guarantee that everything gets shutdown (dropped) properly to terminate network requests, clean up temporary files, clear security-related data and similar things.

anderdrache
Автор

so it's just rust added more steps, to prevent the user from making the system crash, interesting :) 💡

hamdysaadpersonal
Автор

I would be intrested in seeing if statically linking libc musl into rust and build with panic abort would reduce the amount of syscalls. Half the syscalls here appear to be done by ldd and not the actual program itself. A statically compiled programm does not use ldd.

uxel-gy
Автор

Dang I wrote an ASM program that war only slightly more complex than this and it used 3 syscalls (fstat, mmap, print). EDIT: I recounted and it's 5, although 2 of them wouldn't have been needed for this (exit and close).

guyno_one
Автор

Pretty sure you can at least half the number of system call in C

edhyjoxenbyl
Автор

Very interesting analysis. I understand the need for system calls for Memory Management, Security, Loading modules, and basic IO streams during the startup.

But if a large number of system calls are a performance hit, what we can do is reduce the number of system calls in the runtime.

I am currently playing with IO_URING on Python's async await architecture, and it does reduce the number of system calls significantly for large IO loads like servers.
Python's default asyncio library uses a select-based reactor model which I always felt useless because it doesn't work on files.

This can be achieved with any language. I don't think any modern language is truly superior just based on the least amount of system calls while ignoring other benefits.

earthk
Автор

very interesting ! Thank you for the video

inconnuinconnu
Автор

do these numbers count calls from the dynamic linker? (would that even matter for comparisons anyway?)
edit: nvm, seconds after sending this he notes ld.so in some of the calls

aetherclouds
Автор

frankly loading pthreads for no reason is a fail. modern c is pretty trash too, and elf binaries do no service to this problem. this program should be 3 words or less.

Jalae
Автор

What if you build a static binary instead ?

matthieu
Автор

Very good explication. I follow Nasser, he has very interesting topics.

iulikdev
Автор

signals don't need threads in c
you should try to add libpthread to your empty c bin and still compare the calls

also the original video by Hussein makes no sense imo
most of these system calls are only called once and the cost will be amortized over thte long run for something like a webserver
a better approach would be to open and read form a file 10000 times tom compare the calls
or onlt strace after the initial startup but it's harder to do

cunningham.s_law
Автор

Dumb to think it’s ok to do a lot of stuff when it can be done with less. The good question was risen in the original video, isn’t it a good time to take a step back, sit and rethink the approaches. Combining calls? Adding some one-means-a-bunch calls to the api? Other ideas?
I’m not a kernel developer and know nothing about that but those questions seem reasonable.

kamurashev
Автор

Are you sure you need to unwind to retrieve the memory?

julesoscar
Автор

which version of rust are you using? i ran the same code and it only used 73

nebularzz
Автор

As a new grad (working for non system-related program), I have been always wondering how I can always get interested in these types of topics and get more understanding about these topics. How did you learn and improve through your life? I think this is more what I need to become better engineer or programmer to understand what it is exactly happen. Can you give me some advice?

Ubermenschiswhat
Автор

So, what does this mean? program performance, execution speed, compile time, or...?

O...Maiden...O
Автор

What you said doesnt make sense at all. Rusts memory safety happens in compile time not runtime. And tell me which system call improves safety? You just said bunch of nonsense. And additionally you didn't remove the includes in c code.

CrazyWinner
Автор

04:05 you literally didn't remove the includes, how is that an apple to apple comparison?

barry_wastaken