5 ms·
> Rust threads on linux use 8kb of memory Seemly wildly off unless Rust's docs are just wrong? So it's literally the “kilobytes vs megabytes” claim he dismisse
by tick_tock_tick 3y ago
> Rust threads on linux use 8kb of memory
Seemly wildly off unless Rust's docs are just wrong? So it's literally the “kilobytes vs megabytes” claim he dismisses....
https://doc.rust-lang.org/std/thread/#stack-size https://doc.rust-lang.org/std/thread/#stack-size
The default stack size is platform-dependent and subject to change. Currently, it is 2 MiB on all Tier-1 platforms.
- p1necone 3y agoThe stack size starts at 2mb, but unless the code in the thread actually uses that it doesn't really get consumed, because virtual memory.
- deleted 3y ago[deleted]
- insanitybit 3y agoI think this is pretty well covered in the article: > Now you might think that to make a new thread I need 8 megabytes of RAM free. But thanks to the magic of virtual memory and overcommit, that’s not necessarily the case. The right way to think about this is that the OS, let’s assume 64bit, is going to allocate you your own private range but this doesn’t really have to be backed by anything. There are alot of 8mb blocks in a 64bit address space. However there is some book keeping overhead as the kernel tracks it’s IOUs. This is to say that just because you allocate 8MB doesn't mean you create the backing pages and page them in.
- tick_tock_tick 3y agoI know how virtual memory works they are just arguing both sides in the article.