Skip to content
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

Thread.Sleep(0) On Socket.Recv(int timeout) causes 100% core utilization on .net 3.5 #48

Closed
gbaurand opened this issue Feb 21, 2012 · 3 comments
Labels

Comments

@gbaurand
Copy link

When doing a socket.Recv(1000) with a slow or temporary unavaible server, the call is CPU intensive because on .net 3.5, the loop involves a Thread.Sleep(0). (On .net 4, replaced by a Thread.Yield)

I encountered the problem when doing fault tolerance test with a server going down intermittently.

Replacing with Thread.Sleep(1) solves the problem.

@jgoz
Copy link
Contributor

jgoz commented Feb 21, 2012

Hmm, I'll run some tests using Thread.Sleep(1) instead and issue a fix ASAP. Thanks for reporting this.

@jgoz
Copy link
Contributor

jgoz commented Feb 21, 2012

Actually, can you submit this change as a pull request on the 2.2 branch?

@jgoz jgoz closed this as completed in cf971c7 Mar 28, 2012
@jgoz
Copy link
Contributor

jgoz commented Mar 28, 2012

A possible explanation for the problem you were seeing is on Joe Duffy's blog.

hconceicao pushed a commit to castlestronghold/clrzmq2 that referenced this issue May 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants