logoalt Hacker News

Pannoniae • today at 5:47 PM • 2 replies • view on HN

Great article :D The rabbithole actually goes even deeper because buffering on the read side is almost always good, but reads are often way more latency-sensitive than writes. Which leads to the paradox that increasing the buffer size / prefetching more with mmapping can lead to worse performance due to the added latency. And decreasing the buffer size can have the same effect due to issuing more calls, so in order to squeeze in the optimal throughput/latency ratio on reads you have to tune it per workload.... or just try a few different buffer sizes and see which one works better.

Writes are the opposite, they're usually not RAW (read-after-write), they're "fire and forget", so you don't really care about latency, but you do care a whole a lot about your writes actually arriving... again two competing parameters because the more you batch the writes, the faster they are but the bigger chance of a torn write or data loss. And unlike reads, writes are not idempotent on the application level so ideally you'd want some logic to atomically write a meaningful amount of data so it won't get torn, even if it crashes.

Now in practice just about no one actually does any of this but it's a fun thought :D


Replies

Insimwytim • today at 6:51 PM

I have committed a sin of starting with the comments without reading an article, assumed it was about reading and writing text by humans and was increasingly confused by your first paragraph.

I tried to translate it as metaphor at first, but it didn't end up being coherent.

➕ show 1 reply
plasticchris • today at 9:12 PM

Makes sense. If you are reading something you need it to make progress, if you are writing you are finished.