-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
track active domain for nextTick for node.js 0.10.xx #124
Conversation
Promises make domains worthless anyway. |
I'd not say so. Right now libraries like knex do not work as expected in BTW. Why do you say worthless?
|
See #51 |
Although promises do a better job of error handling than domains, you might be using domains for other purposes. For instance, using them for a request context. Are there any disadvantages to using |
Yes, they do completely different things. If anything setImmediate can be used but that's still different - see stackoverflow.com/questions/15349733/setimmediate-vs-nexttick
|
@wless1 is right, if i were using |
I would easily say performance - setTimeout requires the use of timers. |
ty On Sun, Mar 2, 2014 at 7:22 PM, Petka Antonov [email protected]:
|
Why it's been closed? Any comments at least? |
The explanation comment was posted right before closing:
|
Well, fair enough, but at the same time we have very interesting situation here. What's worse? Slower library or library that doesn't work at all as soon as you or another library start using domains. BTW. It's possible to implement the fix for domains in bluebird using nextTick. We just have to track the active domain in schedule.js. Will you consider it as an appropriate solution? It shouldn't affect the performance. |
@xaka If you can truly do it without affecting performance, then why not. But as @benjamingr says, domains are useless and people not using them should not pay anything. |
@petkaantonov I've updated the patch. Please take a look and let me know what do you think of it. https://github.com/xaka/bluebird/compare/patch-1. |
BTW. Domains are very useful for things like http://andreypopp.github.io/domain-context/. It's just the question of size and type of your project. |
Looks good to me, just needs to include a test. You can see how previous node-only tests are done by grepping for |
Could you please re-open PR so i can keep posting the updates. I'll change the title and commit message to not confuse with the initial proposal. Thank you! P.S. If you want me to open another PR and keep this one closed, i don't mind. It's your call. |
@petkaantonov The test has been added. Please take a look when you have a chance. |
How do the benchmarks look? Does the extra check have any impact when not using domains? |
@benjamingr extra check for Node.js version happens only once at compilation time so it doesn't affect the performance at all. Another check for active domain happens at runtime, but as it's very simple IF condition without additional computation, I'd say we've lost only few cycles. P.S. To all, as you understand, this fix is for 0.10.xx version only, so my question is do we care about any version prior to 0.10.xx? |
Is it necessary to call require("domain") each time? |
No, there is no reason to do so. I've updated the patch :) |
I will publish 1.0.8 later today that includes this patch |
@petkaantonov i feel so bad and embarrassed now, but after digging into The improved fix would not cache
And there is no need to check for |
@xaka it seems according to your NodeJS pr that this might get fixed soon in Node :) That's really good news. |
@benjamingr i'm trying really hard to escalate it :) hehe. Thanks to @tjfontaine who agreed to jump on it vey quickly. When community acts like this it makes me happy. |
@benjamingr aaannnddd it's been fixed for 0.10.xx! |
@xaka awesome! Does this mean we can revert this change in BB once it lands in a stable |
Sure thing! I would repatch it with my recent update though which makes @xaka https://github.com/xaka awesome! Does this mean we can revert this change in BB once it lands in a stable Reply to this email directly or view it on |
This PR broke browserify. |
The issue was that a reference was cached instead of loading it over and over again at runtime: var cached = process.nextTick;
function callCached() {
//What if process.nextTick has been changed by now?
//the variable cached will be out of sync
cached();
} vs function callFresh() {
//What if process.nextTick has been changed by now?
//It will call the fresh one
process.nextTick();
} |
No description provided.