ftpd
ftpd copied to clipboard
CPU usage pegged at 100%
Using bin/ftpdrb on macOS with ruby 1.4, Activity Monitor shows ruby using 6 threads and 100% of a CPU. Is the server doing a lot of polling? In my configuration, there are 3 active server connections that are otherwise idle most of the time.
No polling. Ffpd runs one listener thread and then one thread per connection. All IO is supposed to be blocking but what you are seeing makes me wonder.
On Jun 25, 2017 08:47, "pcbeard" [email protected] wrote:
Using bin/ftpdrb on macOS with ruby 1.4, Activity Monitor shows ruby using 6 threads and 100% of a CPU. Is the server doing a lot of polling?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wconrad/ftpd/issues/47, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2JiA6biP4atwrp-Bk_EqSWJDXgTsbRks5sHoD6gaJpZM4OEpDU .
Even w/o any connections, simply starting the server by running bin/fptdrb, here's what top shows:
PID COMMAND %CPU TIME #TH COW #PORT MEM PURG CMPRS STATE UID #WQ BOOSTS %CPU_ME
17058 ruby 94.2 02:02.52 3/1 237 24 8960K 0B 0B running 5322 0 *0[1] 0.00000
The problem was a busy-loop in bin/ftpdrb. I can't release a new gem right now--something in my test/release setup for ftpd has gone wrong, and I can't troubleshoot it right now.
Yes, I just confirmed that too. Here:
def run
puts "FTP server started. (Press CRL+C to stop it)"
connection_info.each do |key, value|
puts "#{key}: #{value}"
end
$stdout.flush
begin
loop{}
rescue Interrupt
puts "\nClosing FTP server..."
end
end
What's your proposed fix? I think the easiest would be to simply change that loop to a call to the server thread's join method.
Added a pull request.
I think your fix is fine. I'll probably back out my fix and accept your PR after I get some of ftpd's housekeeping taken care of.
I've released a new version of the gem which includes my fix for this issue. Leaving this issue open tor remind me to replace it with your fix.
Did you ever consider my fix?
@pcbeard I would love to use your fix. I haven't pulled it in because my upkeep of ftpd stopped when recent versions of Ruby broke the double-bag-ftps gem that ftpd uses for ftps support, and I don't know what the fix for that is. I suppose I could officially not support more recent Ruby versions, but that bothers me.