The fs moduleNode.js · from first principles
one call · four syscalls · 41 operations

Reading a file is not
an operation. It is a queue.

The fs module has two shapes worth knowing, and they answer different questions. One is the arc: what actually happens between fs.readFile(path, cb) and your callback, which turns out to be four separate syscalls, a thread that is borrowed and returned four times, and a buffer allocated before a single byte has been read. The other is the surface: 41 operations, three flavours, and a set of edges where the intuitive thing and the correct thing come apart.

13
Steps in the arc
41
Operations
13
Close-ups
12
Sharp edges
v22.22.2
Measured on
Back to JIT-Atlas