-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Wrong poll timeout behavior in asyncdispatch #4262
Comments
I think the best resolution for this issue is to set default value for asyncdispatch.poll timeout to 0ms. |
I don't think that's a good idea. It can lead to 100% CPU usage when there is absolutely nothing being done by the program. |
@cheatfate maybe we should use (-1 / indefinite blocking timeout) as a default value, not 0ms which will use 100% cppu |
I'm not sure what setting it to |
@dom96 that was a thought in general (against 0ms timeout), that default poll timeout must be infinite, it doesn't fix the bug though |
@dom96, of course it can lead to 100% cpu usage, but if it happens, then something wrong with your application... |
No, there is nothing wrong with your application in that case. It's the |
@dom96, we are using this case only for tests... there no real word case to use asyncdispatch in such way... |
@dom96 and also, if your case exist why asyncdispatch has this check: |
If we change |
Ok, one more idea. |
I'm guessing that @yglukhov's example is simplified. He might actually have descriptors registered in his selector. |
@dom96 actually, firstly the bug was discovered when |
I think my new idea will resolve bug, because nimongo uses some kind of hack for asyncdispatch to poll connections. |
Link? |
I dont know @dom96, what hack using nimongo, i just think it has... because this is very strange situation... |
@yglukhov, so we just leaving this issue? |
@yglukhov, @SSPkrolik i think i know what the problem has nimongo. |
If that is indeed the problem then it seems the solution is simple:
|
@cheatfate Yes, you're right, the problem is with the Anyway, in this case (calling P.S. |
this is not @dom96 solution, this is mine solution :) the problem is that selectors.nim don't count registered/unregistered descriptors. |
@SSPkrolik but i still can't understand why you are fall to 500ms timeout if you have sleepAsync(1) in your |
Great minds think alike :) |
@dom96 ok, but my post about this idea was 2 days ago :) |
@cheatfate We fall into timeout because sleepAsync(1) is only called when all sockets are busy, and in case of tests, all requests are done sequentially, that's why we always get first socket which is free, and sleepAsync(1) is never called. |
The program will take 0.5 seconds to execute, but it should be instant
The text was updated successfully, but these errors were encountered: