# Buffered writes hide errors in a way reads never do

Original title: Reading and writing are less symmetric than you (probably) think

> Hacker News story 50271052 · language: en · submitted 2026-10-28
> Web version: https://zeli.app/story/50271052
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 130 · by [luu](<https://news.ycombinator.com/user?id=luu>) · 💬 30
[original](<https://fgiesen.wordpress.com/2015/10/25/reading-and-writing-are-less-symmetric-than-you-probably-think/>) · [HN discussion](<https://news.ycombinator.com/item?id=50271052>)

## Summary

Reading and writing look like mirror-image I/O operations, but buffering breaks the symmetry. A failed read surfaces its error before fread returns, so you never see bad data. A buffered write returns success immediately, while the real write, and any error, is deferred until the buffer flushes or the file closes. Most programmers check fwrite's return code but forget fflush, fclose, and fsync, so they never learn whether their data actually reached storage.

## Key quote

> Buffered writing delays making the actual write system call; that's kind of the point. But it implies that error reporting is delayed too!

## HN discussion (30 comments)

### [Pannoniae](<https://news.ycombinator.com/item?id=50318282>)

> 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

### [1317](<https://news.ycombinator.com/item?id=50317538>)

> oh i thought this would be about language and how the brain works, that article sounds more interesting to be honest sorry

### [vatsachak](<https://news.ycombinator.com/item?id=50317385>)

> This is true even at the CPU cache level so it's probably going to trickle down all the way.
>
> For example Jon G gave a talk at Jane Street about how he had a mysterious performance bug that was later attributed to cores fighting over the same cache line
>
> https://youtu.be/tND-wBBZ8RY?is=624w3YoDN2QYBWuD

### [rwmj](<https://news.ycombinator.com/item?id=50318279>)

> In any discussion of read, write & sync, I'd want to talk about write amplification (read/modify/write cycles), and also in Linux the sync_file_range syscall which is a useful way to sync part of a file.

### [zahlman](<https://news.ycombinator.com/item?id=50323571>)

> (2015)
>
> I don't know why I'd "(probably) think" they're anything like symmetrical. After all, I have first-hand experience of reading code and writing code; clearly, very different processes.

---

## Cite

- Page: https://zeli.app/story/50271052
- Date: 2026-10-28
- Source: fgiesen.wordpress.com (https://fgiesen.wordpress.com/2015/10/25/reading-and-writing-are-less-symmetric-than-you-probably-think/)
- Hacker News: https://news.ycombinator.com/item?id=50271052

## Other languages

- zh: https://zeli.app/zh/story/50271052 · markdown: https://zeli.app/zh/story/50271052.md
- ja: https://zeli.app/ja/story/50271052 · markdown: https://zeli.app/ja/story/50271052.md
- ko: https://zeli.app/ko/story/50271052 · markdown: https://zeli.app/ko/story/50271052.md
- de: https://zeli.app/de/story/50271052 · markdown: https://zeli.app/de/story/50271052.md
- es: https://zeli.app/es/story/50271052 · markdown: https://zeli.app/es/story/50271052.md
- ru: https://zeli.app/ru/story/50271052 · markdown: https://zeli.app/ru/story/50271052.md
