Does Your await Actually Reach the OS? Peeking at JavaScript's Async with strace
We write async/await as a matter of course, but when asked "what is the OS actually doing while you're waiting?", I could only give a vague answer, and it bothered me. So in this lightning talk, I'll dig into Node.js code down to the system call level using strace, to see what await really is under the hood.
First, comparing Promise.resolve() and fetch() reveals that there are two kinds of await: ones that actually descend to the OS, and ones that don't. Next, I'll run multiple fetch calls both "sequentially" and via Promise.all, and line up the syscall logs side by side. This reveals that what makes things parallel isn't Promise.all itself — its real effect is in consolidating the round trips of epoll_wait.
Finally, I'll connect this perspective to cases where Nuxt's useAsyncData/useFetch end up running sequentially and becoming slow, so that you can walk away able to explain, in the OS's own terms, "why bundling requests together makes things faster."
Hasuto
Does Your await Actually Reach the OS? Peeking at JavaScript's Async with strace
We write async/await as a matter of course, but when asked "what is the OS actually doing while you're waiting?", I could only give a vague answer, and it bothered me. So in this lightning talk, I'll dig into Node.js code down to the system call level using strace, to see what await really is under the hood.
First, comparing Promise.resolve() and fetch() reveals that there are two kinds of await: ones that actually descend to the OS, and ones that don't. Next, I'll run multiple fetch calls both "sequentially" and via Promise.all, and line up the syscall logs side by side. This reveals that what makes things parallel isn't Promise.all itself — its real effect is in consolidating the round trips of epoll_wait.
Finally, I'll connect this perspective to cases where Nuxt's useAsyncData/useFetch end up running sequentially and becoming slow, so that you can walk away able to explain, in the OS's own terms, "why bundling requests together makes things faster."
