diff options
author | Eric Wong <e@80x24.org> | 2016-06-07 04:07:18 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-06-07 04:07:39 +0000 |
commit | 46614f480a8b8f54ee32e670306c554d016bf3df (patch) | |
tree | e02651cbac3a6f97ab46b3493c86804fe6d433d4 /lib/yahns/fdmap.rb | |
parent | 77aac8c54ac030b08cfe6bcafc6fd155854456a7 (diff) | |
download | yahns-46614f480a8b8f54ee32e670306c554d016bf3df.tar.gz |
Using a 10ms tick was too little, use 100ms instead to avoid burning CPU. Ideally, we would not tick at all during shutdown (we're normally tickless); but the common case could be slightly more expensive; and shutdowns are rare (I hope). Then, change our process title to indicate we're shutting down, and finally, cut down on repeated log spew during shutdown and only log dropping changes. This mean we could potentially take 90ms longer to notice when we can do a graceful shutdown, but oh well... While we're at it, add a test to ensure graceful shutdowns work as intended with multiple processes.
Diffstat (limited to 'lib/yahns/fdmap.rb')
-rw-r--r-- | lib/yahns/fdmap.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/yahns/fdmap.rb b/lib/yahns/fdmap.rb index fab5d36..0aaf360 100644 --- a/lib/yahns/fdmap.rb +++ b/lib/yahns/fdmap.rb @@ -89,10 +89,10 @@ class Yahns::Fdmap # :nodoc: # We should not be calling this too frequently, it is expensive # This is called while @fdmap_mtx is held def __expire(timeout) - return if @count == 0 + return 0 if @count == 0 nr = 0 now = Yahns.now - (now - @last_expire) >= 1.0 or return # don't expire too frequently + (now - @last_expire) >= 1.0 or return @count # don't expire too frequently # @fdmap_ary may be huge, so always expire a bunch at once to # avoid getting to this method too frequently @@ -104,8 +104,11 @@ class Yahns::Fdmap # :nodoc: end @last_expire = Yahns.now - msg = timeout ? "timeout=#{timeout}" : "client_timeout" - @logger.info("dropping #{nr} of #@count clients for #{msg}") + if nr != 0 + msg = timeout ? "timeout=#{timeout}" : "client_timeout" + @logger.info("dropping #{nr} of #@count clients for #{msg}") + end + @count end # used for graceful shutdown |