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

CPU usage pegged at 100% #47

Open
pcbeard opened this issue Jun 25, 2017 · 9 comments
Open

CPU usage pegged at 100% #47

pcbeard opened this issue Jun 25, 2017 · 9 comments

Comments

@pcbeard
Copy link

pcbeard commented Jun 25, 2017

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.

@wconrad
Copy link
Owner

wconrad commented Jun 25, 2017 via email

@pcbeard
Copy link
Author

pcbeard commented Jun 26, 2017

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

wconrad added a commit that referenced this issue Jun 26, 2017
@wconrad
Copy link
Owner

wconrad commented Jun 26, 2017

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.

@pcbeard
Copy link
Author

pcbeard commented Jun 26, 2017

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.

@pcbeard
Copy link
Author

pcbeard commented Jun 26, 2017

Added a pull request.

@wconrad
Copy link
Owner

wconrad commented Jul 16, 2017

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.

@wconrad
Copy link
Owner

wconrad commented Jul 17, 2017

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.

@pcbeard
Copy link
Author

pcbeard commented Sep 13, 2021

Did you ever consider my fix?

@wconrad
Copy link
Owner

wconrad commented Sep 13, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants