Adam Hooper
1 min readSep 6, 2018

--

Good ideas.

As I wrote in the article, reading all the files in parallel — in this specific benchmark — leads to EMFILE: too many open files. Promisify in parallel would do the same thing.

I added promisify in serial to see whether it’s any faster. It’s far slower than async. That’s not too surprising: it’s probably implemented in terms of async anyway.

We could try batching reads so we only open 1,000 files at a time. But why? Node’s async strategies add 500ms or 1s of overhead to ~100ms of useful work. If batching somehow makes the useful work take 10x less time, the entire task will still cost 500ms or 1s in overhead.

So the original point stands: async methods are very expensive — often more expensive than synchronous I/O. Developers should always consider whether the overhead is worthwhile.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

 by the author.

--

--

Adam Hooper
Adam Hooper

No responses yet

Write a response