Тёмный

How many kernel system calls do runtimes make? 

Hussein Nasser
Подписаться 430 тыс.
Просмотров 11 тыс.
50% 1

Опубликовано:

 

20 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 84   
@hnasr
@hnasr 6 дней назад
Learn more about how the kernel (Windows and Linux) , get the Fundamentals of Operating Systems oscourse.win
@shapelessed
@shapelessed День назад
So, the video was published 5 hours ago but uploaded at least 4 days earlier… Interesting…
@juangomez4133
@juangomez4133 День назад
Hussein in a few years. "I want to discuss the electric flow in the motherboard when you do network request"
@jskr456
@jskr456 День назад
looking forward for it , so finally i can understand how network connections are made and data flows between them
@thisisneeraj7133
@thisisneeraj7133 День назад
More looking forward for how silicon quality makes software slow
@greyshopleskin2315
@greyshopleskin2315 15 часов назад
@@jskr456there’s little people of the network card shouting through the network cable. And in the receiving computer there’s little people listening. Don’t let big network deceive you
@MarekKnapek
@MarekKnapek День назад
The write is about writing to the screen. Under the hood it writes to standard output. Under the hood it writes to a file descriptor. Under the hood the file descriptor describes a terminal "device".
@matveyshishov
@matveyshishov День назад
The year was 2024. The Internet discovered system calls. Next season: containers are just processes; blinking an LED with TypeScript; .eh_frame section.
@thydevdom
@thydevdom День назад
Man I’ve been following you and your podcast for a few years. You are heaven sent and a great teacher.
@casperx102
@casperx102 День назад
c do no bullshit, straight to the point
@7heMech
@7heMech День назад
So happy you jumped on Bun as well.
@KangJangkrik
@KangJangkrik День назад
Since we have heated debate between C vs Rust in Linux community, please also try to test Rust with this. Thank you!
@omarbarra3456
@omarbarra3456 16 часов назад
That is what I was thinking about!!!
@7heMech
@7heMech День назад
For Bun maybe you should've used Bun.file API, also AI can't write Bun (except for the one on their website)
@sharmojj
@sharmojj 16 часов назад
ai can not do shit
@anamulakash2201
@anamulakash2201 День назад
Awsome explanation. I was exploring ebpf and got notification from your chanel
@MarekKnapek
@MarekKnapek День назад
At the end you described iouring, but it cannot be used everywhere, because sometimes you need to know result of one syscall in order to decide whether or which syscall to perform next. If you bring this to the extreme, everything will be running in kennel space. Enter eBPF.
@btimbyindy
@btimbyindy День назад
To address that you would need a simple embedded vm or language in the kernel, like how redis uses lua. But that could be a security nightmare.
@ryanseipp6944
@ryanseipp6944 День назад
14:37 The write syscall is also used to print stdout
@Sonyim414
@Sonyim414 День назад
Specifically, each line is its own write syscall. First is "File contents:", next is the buffer, next is the empty string after newline. This is really not an equal comparison, because in python he used an iterator to iterate over the lines...
@btimbyindy
@btimbyindy День назад
To your point re: batching calls. Look at sendfile. It takes two file descriptors and moves data from one to another. When switching from userkernel land memory buffers are copied (userspace cannot access kernel space) and that gets very expensive when sending large amounts of data.
@danishmehmood6110
@danishmehmood6110 День назад
thanks for thinking out loud , and letting everyone know that dumb questions and the best ones and they really fill in the loop holes in your understanding , it takes a lot of courage to do that to answer the question you posited at the end of the video - I don't think that would be possible lets assume you are reading a 10 MB file and printing its contents to the screen - lets say you create a 1 mb read buffer , now you read the file and print , to read the whole file , you would need to make the 10 read syscalls (keeping things simple here for understanding ) - now if we employ your idea of making all the calls at once , that would defeat the whole purpose of having a memory buffer for read - if we make all the read calls at once where would OS write the data it has read , because the buffer is only 1 mb and the point of having a buffer is to constrain memory usage.
@wlockuz4467
@wlockuz4467 День назад
This is awesome. I wish you did more languages.
@محمد-م5ث1ش
@محمد-م5ث1ش День назад
I hope you can include Go in your future comparison please
@amadzarak7746
@amadzarak7746 День назад
Hussein, your channel is one of the most valuable channels for any modern developer
@7heMech
@7heMech День назад
Awesome video, I've been thinking about this.
@danieledll
@danieledll День назад
Sorry but this is video has way too many problems ;) (1) The number of syscalls impacts the performances, a context switch between two threads of the same process or a switch to kernel space and back can take up to 5 microseconds, so if you are reading 1 byte at time (silly example eh? sadly not too much :( ) from memory and do absolutely nothing else at maximum you can read 200000 bytes (probably its less but let's pretend it's a perfect world and you don't pay the price of the memory copies and various checks). Even if you pin the thread, you would get down to about 2us and this would mean just 1000000 bytes per second ... New kernel components like io_uring implement VERY complex mechanisms to avoid the need of context switching forth and back from the kernel! (2) The version of nodejs in use is fairly old, beginning of 2022, with the 20.15 (which is the LTS not the latests so there might be even more performance improvements) it's down to below 700 (3) Not clear which is the version of python (4) This is minor but the C code does 1 single printf when instead the nodejs and the python version do 1 print per line, this is minor because the file contains just 2 lines NOTE: I am not a fan of node.js at all lol I like facts ;) EDIT: Also would have made sense to have a comparison with some code that was actually doing something because perhaps a lot of these syscalls are done during the initialization phase and the number of them might be much lower while the code runs. It would have been an important and useful comparison.
@ghassenlabidi5171
@ghassenlabidi5171 День назад
This is what I was thinking too! Plus Bun provides its own way to read files which is way more efficient than using node's "fs".
@danieledll
@danieledll День назад
@@ghassenlabidi5171 to be honest o am not sure of the specifics, I am more highlighting the approach to this specific test / video. I understand that the original. Idea was to highlight all the extra work that these platform do for little reason but it's also very much true that they are built for backend applications and/or long running applications in mind and therefore they are little optimized when it comes to the startup
@btimbyindy
@btimbyindy День назад
To exclude initialization, you could start and end with a specific syscall and use awk to select just the relevant ones between, then shell magic to summarize.
@shpetimselaci5884
@shpetimselaci5884 День назад
Thank you for doing this video. Keep it up!
@hitmusicworldwide
@hitmusicworldwide День назад
Speaking of chat GPT, a lot of times when I'm out jogging in between listening to your RU-vid videos and other videos I will have conversations with the chat GPT voice mode about these sorts of backend and front and integration issues and other technology ideas I have in the same or simular domains. It would be interesting for you to record a voice conversation with your musings about this with chat GPT or PI AI to see how the conversation goes, then follow up on it to find out if it's expressing something useful or not。 You would get immediate feedback from what might be an expert source if you prompt it correctly, and it would also give us the ability to see if it's able to give useful information the way you do when we're not able to have a direct conversation with you.
@rschmidtzalles
@rschmidtzalles День назад
This was a fun watch. Thanks
@energy-tunes
@energy-tunes День назад
Hes the type of prof that could lecture for 10 hours without break
@dhillaz
@dhillaz День назад
It would be interesting to do control runs executing empty source files to adjust for the Python/JS initialization, and deduce the call count of the read action specifically
@vladimirkashitsyn1871
@vladimirkashitsyn1871 День назад
Brilliant! I am going to check java program)))
@yashnikam9189
@yashnikam9189 14 часов назад
I think nodejs python bun require exec to run the file so it might have more syscall but c is compiled in exec and directly executed so it have less syscall.i might be wrong though just my assumption
@passionforsciencel5180
@passionforsciencel5180 День назад
Even working with memory need a syscall like malloc function , you supposed to mention that in the beginning, but thanks for the video anyway. Follow you from Algeria 🇩🇿
@mobod6822
@mobod6822 День назад
malloc isn't a syscall, it's calling the mmap syscall
@passionforsciencel5180
@passionforsciencel5180 День назад
@@mobod6822 Oh , yeh , thanks ❤️
@erisboxxx
@erisboxxx 8 часов назад
Include Go in future comparisons if possible please!
@siya.abc123
@siya.abc123 День назад
I can sense it, another dev tool them all episode is around the corner
@lucasoliveira-xs5yh
@lucasoliveira-xs5yh 14 часов назад
I'm curious (and maybe I'll try it) about Go would behave
@strange-m6u
@strange-m6u День назад
Go is around 185. Node v20.17 is around 695.
@ryanseipp6944
@ryanseipp6944 День назад
With synchronous syscalls, I don't think it's possible to "batch" them. The kernel wouldn't have the arguments. If you objdump the C code, you'll see before each `syscall` instruction, the code places values in specific registers. With io_uring, this batching is straightforward. You can submit 3 SQEs and wait for all 3 to complete. In that time, your program yields to the kernel and the kernel only resumes that thread when everything is ready. Then you can loop through CQEs and get the results.
@abhinavpandey1374
@abhinavpandey1374 День назад
shouldn't we also take into account the system calls that are done anyways without reading files? i feel a lot of those system calls are common for all node processes. also some of those reads are due to the script itself, as node and python also have to read the script passed to them. i feel comparing them to a compiled language like c is a little unfair. a more fair comparison would have been go vs c.
@Aditya_Vyas
@Aditya_Vyas День назад
Hussein is basically saying we need to avoid those kernel-user switching again & again, instead do something like an UPSERT or an Asynchronous call you make in JS. Hussein I thought a little bit, I had a question. Wouldn't an Asynchronous call take more time? You will surely have less system call but execution speed wouldn't be less? And won't it create a problem if the 2nd system call is dependent on the 1st one so it went, came back, bought some metadata(read write) and the 2nd call uses it with some of the users input? I'm probably mad or I should do some breathing exercises.
@mage3690
@mage3690 23 часа назад
You could use command buffers and queues, the way Vulkan does. And IDK anything about how any of this works, but if Vulkan does it, I'm inclined to think it's fast.
@Aditya_Vyas
@Aditya_Vyas 23 часа назад
@@mage3690 interesting
@williandamascenomusic
@williandamascenomusic День назад
WTF, your videos are so fucking interesting, well done!
@oleholgerson3416
@oleholgerson3416 День назад
The real (and unsurprising) takeaway for me was how ugly javascript is… Can‘t even read from a file without wrapping everything in a lambda, just so that you can await something. JS really gives me nightmares
@dasten123
@dasten123 День назад
No you don't have to write it that way
@btimbyindy
@btimbyindy День назад
There are sync versions of those calls.
@AHMED-et7md
@AHMED-et7md День назад
what about using node last version using V8 maybe low time more then C.
@dmitrykim3096
@dmitrykim3096 День назад
Well it reads the script first parses it and them runs it, so ofc there will be an overhead
@algorithm1313
@algorithm1313 19 часов назад
When did you move to vim!???
@dasten123
@dasten123 День назад
It's interesting stuff, but I this was a very unfair comparison because the programs did completely different things and I really don't get why you are using an ancient Node version
@rsroyalrahul5
@rsroyalrahul5 23 часа назад
can you please do Go, Rust, Zig, Java please?
@alkolaqi83
@alkolaqi83 День назад
Whats the point of doing bun, should’ve done go/rust
@engine_man
@engine_man 23 часа назад
Sorry… why would he do rust/go? Are you just regurgitating whatever is trending?
@alkolaqi83
@alkolaqi83 11 часов назад
@@engine_man exactly
@shubhambaranwal7613
@shubhambaranwal7613 День назад
I think you are not giving node bun and pthon a fair chance. Sure the c program is fast but if you think carefully we also need to make trace of when we are making the .out executable filein c. We are executing that file but to execute that file we need to first make it and that will surely take more syscalls. Just a observation to point out
@oll236
@oll236 День назад
Omg update node. Can someone get the stats?
@bean_TM
@bean_TM День назад
the javascript code could have been much better. especially with such an ancient version of node. i think it misrepresented how bad JS is. JS is bad. but not that bad (copium)
@mintoo2cool
@mintoo2cool День назад
should have compared cat command too...
@kaushik.aryan04
@kaushik.aryan04 День назад
I though bun was supposed to be faster than node
@andreilucasgoncalves1416
@andreilucasgoncalves1416 День назад
He is testing an older version of node, the current can be even slower. The reason can be many things like security updates or support to new features
@CjqNslXUcM
@CjqNslXUcM День назад
This is a dumb comparison. No one starts a seperate runtime for every file they open. You should open the runtime before measuring.
@shapelessed
@shapelessed День назад
Watch out mistaking a library for a framework, let alone runtimes in the JS community… You’re either gonna start a third world war or end up in a mysterious us accident, really dangerous thing to get wrong…
@MrAtomUniverse
@MrAtomUniverse День назад
Where is rust
@seydullanarkulyyev2729
@seydullanarkulyyev2729 6 дней назад
🔥🔥🔥
@shapelessed
@shapelessed День назад
I think this “benchmark” is quite frankly flawed. Not because it doesn’t show anything, it’s because it shows things in the wrong light. What you have showcased here is not the objective speed of execution of these runtimes and the number of system calls they make, but the behaviour they show when starting the environment, reading configuration, writing startup logs and all the things they do right on start, which they then almost completely stop doing. The program you wrote in C? - It’s compiled, it has no need to set things up as it’s been done in advance by the compiler. So many people structure their benchmarks in a way that is objectively flawed simply because interpreted languages require some startup overhead put in place by the runtime that simply isn’t there with precompiled programs. If we were to play a fair game, we would need to benchmark the compiler doing its own things together with the compiled program against a script running inside of a runtime.
@TheOnlyJura
@TheOnlyJura День назад
lol, no
@shapelessed
@shapelessed День назад
@@TheOnlyJura Sure, a guy comes with an actual argument to which some random on the internet says "lol no" and leaves. Either provide an argument or leave jerk off.
@shapelessed
@shapelessed День назад
@@TheOnlyJura lol, not an arument
@developersharif
@developersharif 16 часов назад
😮
@shafiq_ramli
@shafiq_ramli День назад
So is bun a scam?
@andreilucasgoncalves1416
@andreilucasgoncalves1416 День назад
No, there are two things to consider here, it is not a full application and the node version is too old
@fourcoding3198
@fourcoding3198 День назад
​@@andreilucasgoncalves1416 Bun is standalone, i.e. it is independent from the installed node
@btimbyindy
@btimbyindy День назад
Also, bun may have more startup overhead even if the actual script execution is faster.
@vishnuvarthan4028
@vishnuvarthan4028 5 дней назад
Awesome content as usual
@nitsanbh
@nitsanbh День назад
14:40 isn’t that write just the printf?
Далее
Why Inkscape writes everything twice
10:24
Просмотров 21 тыс.
I regret doing this...
1:20:07
Просмотров 73 тыс.
How to Install and Use an Adjustable TV Arm
00:18
Просмотров 2 млн
They made Kafka 80% faster by switching file systems
31:30
Why the Windows kernel can connect slower than Linux
35:50
I tried Swift and came out a different person
1:56:59
Просмотров 73 тыс.
Postgres just got even faster
26:42
Просмотров 24 тыс.
TETRIS CLONE! // Code Review
36:55
Просмотров 12 тыс.
The effect of Random UUID on database performance
18:51
Programming w/o Language
1:47:00
Просмотров 54 тыс.