- register - shadow register - L1 - L2 - L3 - RAM - GPU/SPU/RSP - SSD - Network - HDD The line is drawn depending on what you are doing and how. Edit: moved Network above HDD. :-)
I would put networks above HDDs (depending on how many miles you need to send your emails)
Async hazard: MMAP is blocking IO
21–30 of 119 posts
Re: Async hazard: MMAP is blocking IO
#22Earlier quoted context omitted.
> how could it possibly not block? When the bytes being read are already in the cache. Hence the later part of the article where the author shows that reading mapped memory can be significantly faster.
It still blocks. It just completes orders of magnitudes faster.
Re: Async hazard: MMAP is blocking IO
#23Earlier quoted context omitted.
> how could it possibly not block? When the bytes being read are already in the cache. Hence the later part of the article where the author shows that reading mapped memory can be significantly faster.
It still blocks. It just completes orders of magnitudes faster.
You could say that any non-register memory access "blocks" but I feel that's needlessly confusing. Normal async code doesn't "block" in any relevant sense when it accesses the heap.
Re: Async hazard: MMAP is blocking IO
#24Re: Async hazard: MMAP is blocking IO
#25Earlier quoted context omitted.
It still blocks. It just completes orders of magnitudes faster.
Do you consider reading from a normal array (one not backed by a memory mapped file) to also be blocking?
Re: Async hazard: MMAP is blocking IO
#26I like this point - it's no secret that mmap can make memory access cost the same as an IO (swap can too) - but the interaction with async schedulers isn't immediately obvious. The cost can, sometimes, be even higher than this post says, because of write back behavior in Linux. Mmap is an interesting tool for system builders. It's super powerful, and super useful. But it's also kind of dangerous because the gap betwe…
the blog post points (in my mind) at some more general advice when programming which is not to mix and match paradigms unless you really know what you're doing. if you want to do user space async io, cool. if using kernel features tickles your fancy, also cool.
mixing both without a deep understanding of what's going on under the hood will probably give you trouble.
Re: Async hazard: MMAP is blocking IO
#27Earlier quoted context omitted.
It still blocks. It just completes orders of magnitudes faster.
No, if the memory-mapped page you're accessing is in RAM, then you're just reading the RAM; there is no page fault and no syscall and nothing blocks. You could say that any non-register memory access "blocks" but I feel that's needlessly confusing. Normal async code doesn't "block" in any relevant sense when it accesses the heap.
As such a regular memory read is blocking, in that control will not switch while you're doing the read (ie your not doing anything else while it's copying). This is unlike issuing an async read, which is exactly a point where control can switch.
edit: As an example, consider synchronous memory copy vs asynchronous DMA-based memory copy. From the point of view of your thread, the synchronous copying blocks, while with the DMA-based copying the thread can do other stuff while the copying progresses.
Re: Async hazard: MMAP is blocking IO
#28Earlier quoted context omitted.
Do you consider reading from a normal array (one not backed by a memory mapped file) to also be blocking?
In the languages and platforms I use, absolutely yes. Do you have some examples where a normal memory read is async?
If you consider all memory reads to be "blocking", then everything must be "blocking". The executable code must, after all, be read by the processor. In an extreme case, the entire executable could be paged out to disk! This interpretation is not what most people mean by "blocking."
Re: Async hazard: MMAP is blocking IO
#29Earlier quoted context omitted.
> how could it possibly not block? When the bytes being read are already in the cache. Hence the later part of the article where the author shows that reading mapped memory can be significantly faster.
It still blocks. It just completes orders of magnitudes faster.
Re: Async hazard: MMAP is blocking IO
#30water is wet