From: Raul Parolari Date: 2010-04-28T03:27:54+09:00 Subject: Re: Networking: select() blocks for seconds (> timeout) Caleb Clausen wrote: > On 4/25/10, Raul Parolari wrote: >> >> All is perfect for several thousands of messages, until this: we receive >> data (in the "else" branch) 5 seconds later; so, the select remained >> blocked for 5 seconds without signaling the 50 msec timeout. >>.. >> Finally, I concluded that the garbage collector must be entering in >> action and for a few seconds (that usually are very close to 5) >> everything stops in Ruby. > > I also suspect GC is your issue here. You could try to reduce the > latency cost of GC by forcing GC to happen every time thru the main > loop.... This will reduce the tme it takes for any individual GC cycle > by increasing the total amount of time spent in GC. You might also try > reducing the amount of garbage (and for that matter non-garbage) > objects which your program creates. Thanks Caleb can you point out a link to how to do that (making GC to happen every time?); I found pages which mention setting Ruby Constants, but let me know what is the best page if you have the chance. Regarding reducing amount of garbage, it is a good tip (that I had began to apply); coming from compiled languages, I tend to use a variable for each "entity", so that the final computation looks like a clear mathematical formula (instead of those 140 characters lines that I see all over in Rails which compute everything right there on the line. I begin to understand why they may be doing it.. although I wonder what it must be maintaining such a monstrous code. Hopefully, there is a good compromise). Thanks very much for the suggestions Raul -- Posted via http://www.ruby-forum.com/.