4 ms·
What do you expect to happen in other languages, when your program makes a million calls to `stat()`? Is that something that happens often? What kind of applica
by cuddlecake 6y ago
What do you expect to happen in other languages, when your program makes a million calls to `stat()`? Is that something that happens often? What kind of application needs that? Is there a language that solves this neatly?
(I'm genuinely curious, independent of my newbie elixir evangelism)
- rcxdude 6y agogit, for example, can do this on a large repository when checking for updated files (because it needs to check the modification timestamp of every file in the repo), and for a lot of common operations it's actually the bottleneck (and one reason why it is often faster on linux: the VFS layer in linux puts a lot of effort into making such operations as fast as possible, somewhat appropriately Linus was the one who did a lot of that work originally). In C it works pretty much as expected, and most of the overhead is in the kernel.
- ridiculous_fish 6y agoThis problem doesn't arise in a 1-1 language like C, because the thread spawning will either fail or have obviously terrible performance. These languages push you into using work queues, etc. immediately. But in languages with green threads (like Go), you CAN spawn a million threads and performance will be fine, until you make a syscall. An example of how this can happen: I once wrote a Go tool that walks the filesystem. I spawned a new thread for every directory, thinking that Go only has ~N kernel threads so performance will be fine. I was shocked to see that, in this scenario, it spawns a kernel thread for every green thread!