Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Remove async.waterfall #51

Merged
merged 2 commits into from
Apr 8, 2015
Merged

Remove async.waterfall #51

merged 2 commits into from
Apr 8, 2015

Conversation

pksunkara
Copy link
Contributor

Using async.waterfall is blocking the event loop.

/cc @zdne @honzajavorek @Almad

zdne added a commit that referenced this pull request Apr 8, 2015
@zdne zdne merged commit e3e9503 into master Apr 8, 2015
@zdne zdne deleted the shared/perf branch April 8, 2015 17:30
@Almad
Copy link
Contributor

Almad commented Apr 8, 2015

@pksunkara @zdne I'd be interested in measurement behind this.

async.waterfall is no different from any other function call (that, yes, is blocking by default). But if anything, and if you want to do cooperative multitasking, it should IMHO be easier to wrap waterfall in process.nextTick that allows other things in queue to be executed.

I am not disputing results of your investigation, but I am personally really curious to see how this change affected performance and whether async is really performance hog.

@zdne
Copy link
Contributor

zdne commented Apr 8, 2015

@Almad interesting – with our limited knowledge of this I guess we haven't realized wrapping it in nextTick is the way to go. /cc @smizell

@smizell
Copy link
Contributor

smizell commented Apr 8, 2015

@Almad @zdne In playing around with this last night, something was really strange. I've used async.waterfall a lot and have never seen it.

This would not block the event loop.

return callback()

But if replaced with this exact code, it would block until all calls were finished.

async.waterfall [
  (next) -> next()
], -> callback()

If you did not use this but introduced another async.waterfall in the callback chain, it would block until almost all had been completed.

@smizell
Copy link
Contributor

smizell commented Apr 8, 2015

@Almad @zdne Additionally, in the above example that blocked, if I changed to async.series, it worked.

@honzajavorek
Copy link
Contributor

Could this be related? caolan/async#696 Just browsed through their issues, I did not look into its internals.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants