-
Notifications
You must be signed in to change notification settings - Fork 48
Refactors Bindinds to use Async Workers #193
Conversation
The support code could benefit from some refactoring. |
} | ||
|
||
return engine_config; | ||
static Nan::Persistent<v8::Function> init; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is needed for the thread-safe singleton impl. without relying on global constructors.
This fixes concurrency issues reported in #189. References: - https://github.com/nodejs/nan#asynchronous-work-helpers - https://github.com/nodejs/nan/blob/master/doc/asyncworker.md#api_nan_async_worker - https://github.com/nodejs/nan/blob/master/doc/asyncworker.md#api_nan_async_queue_worker
@daniel-j-h - can you share more about what was wrong with the original code, what the specific fix needed was, and how you confirmed the fix impacted performance? I'm asking because its not clear to me whether the fixes here apply or are relevant to other async code I maintain for other node c++ modules. |
@springmeyer a couple of weeks before this pull request I learned about npm / node / nan by writing node bindings for @danpat's route-annotator. For making its features asynchronous I used NAN's beautiful async. abstractions. More concretely: 1/ inherit from If you take a look at the code before this changeset, Looping in libuv-wizard @kkaefer here. |
@daniel-j-h - Thank you for the clarification. If I am understanding correctly then:
Is that correct? If so, there are dozens of node c++ modules that we (Mapbox) maintain which need fixed because they are using libuv directly, without any known problems. But your findings indicate they are likely not working correct for some reason. So my further questions are:
If you don't know no problem, I'm just trying to understand before diving in to figure out whether we need to change many node c++ modules and why/how. Thanks! |
The code using If you want to dig into this, this is what I would do:
Yes, I'm not sure though what else changed since I haven't had a close eye on
From reading the NAN source, it looks like a really thin wrapper around Hope that helps. |
Thanks @daniel-j-h - I'll try to replicate and dig in when I have time. |
@springmeyer FWIW, it may be that the way We noticed this when we were running benchmarks - we were maxing out at 2 CPUs in use and couldn't drive usage any higher. If you aren't seeing that performance problem elsewhere, then it's probably a non-issue. Rather than diving into what was wrong with our direct usage of |
This fixes concurrency issues reported in #189.
The code changed quite dramatically, better take a look at the files directly
References:
/cc @TheMarex rebased into the initial commit you made for me