Foldit is eating Mac's cpu at close to 90%

Case number:699969-993269
Topic:General
Opened by:auntdeen
Status:Open
Type:Bug
Opened on:Wednesday, August 1, 2012 - 17:28
Last modified:Thursday, August 2, 2012 - 17:25

I had feedbacked in April about hard system hangs on my mac. The problem had disappeared for a while (I ran less clients and only had one open if doing any mutating) but is back.

The mac I am using at the moment is 2.8 GHz intel core duo - older than the one in the original feedback, an 2.8 GHz Intel Core i7) but is still able to run the latest OS. Both are still running OS 6.8 because of work programs.

In the past few days I have again had hard system hangs, so I installed iStat Pro (a widget) to see what % of cpu Foldit was using. Wow, no wonder my system is hanging… All % below are taken from total usage since it often spills into the second core.

Open foldit client - 38%, drops to 6%
Science Puzzle Screen - 45%
Loading Puzzle 607 (only 98 residues) - 76%

Open "Manage Solutions" - 92%

Puzzle screen showing protein and GUI - 72%

Shake - 184%
Wiggle - 180%

Drag protein off screen - 79%
Hide GUI - 33%
Minimize screen - 2%

Start script Quaking Rebuild with protein and GUI showing - 180%
Drag protein off screen - 171%
Hide GUI - 161%
Minimize - 134% (!!!!!)

No wonder I am having system hangs! When I discovered this yesterday, phi16 also downloaded iStat Pro and had similar findings on his Mac.

I switched back and forth between devprev & main with similar results.

(Wed, 08/01/2012 - 17:28  |  16 comments)


tamirh's picture
User offline. Last seen 6 years 18 weeks ago. Offline
Joined: 05/11/2012

The tools that run until you stop them basically have an infinite amount of work to do, so they will run as fast as they can and eat up as much processing power as they can use.

As far as the hangs, you could make foldit a lower priority process since it's probably running in the background when you are using the computer for other tasks. On a mac you can do this: http://superuser.com/questions/42817/is-there-any-way-to-set-the-priority-of-a-process-in-mac-os-x

Joined: 04/19/2009

tamirh - thank you for your quick response.

Just so I'm clear on this, though... You are saying that yes, Foldit is causing the system hangs? That the program is gobbling that much cpu on Macs, and that it's up to the Mac user to either try to confine Foldit by going into the Terminal (following 3 year old advice on a website that I've never heard of) or downloading a GUI utility to control Foldit?

While I am a Mac user that is possibly knowledgeable enough to try to fix the problem by going into the Terminal - and am possibly crazy enough to do this every time I wish to open a client - I suspect that the average Mac user simply won't.

Many people have complained about excessive cpu usage by Foldit, this is just the most recent. It would seem to be a better solution to fix Foldit rather than expect that the players "fix" their computers.

infjamc's picture
User offline. Last seen 2 years 45 weeks ago. Offline
Joined: 02/20/2009
Groups: Contenders

Would it be possible to add an option that allows the user to limit Foldit's maximum CPU usage?

tamirh's picture
User offline. Last seen 6 years 18 weeks ago. Offline
Joined: 05/11/2012

The short answer... not exactly.

It shouldn't be too difficult to add the desired FPS (described below) as a command line argument or to options.txt. Although that would not change CPU usage as much as you may think it would.

EDIT: This desired fps + window width/height should changeable in the options.txt file with the next version of devprev.

infjamc's picture
User offline. Last seen 2 years 45 weeks ago. Offline
Joined: 02/20/2009
Groups: Contenders

In that case, would it be possible to have the option of using less than the maximum number of cores available *in the game itself* (as opposed to using the task manager, etc.)?

tamirh's picture
User offline. Last seen 6 years 18 weeks ago. Offline
Joined: 05/11/2012

The short answer again I'm afraid is no...

We use threads for a few reasons. The main being we want two or more things to happen concurrently. This means the when you are uploading the puzzle to our servers your screen doesn't freeze. When you are wiggling, you are still able to view the protein.

It is the job of the operating system to distribute this work onto one or more cores. The OS usually tries to split jobs across many cores for a lot of reasons, the best one being it just makes everything run faster and programs will seem more interactive.

tamirh's picture
User offline. Last seen 6 years 18 weeks ago. Offline
Joined: 05/11/2012

This is a long post so let me know if any part of it (or everything!) is confusing (=

--- nice/renice/process priority --
As far as nice/renice (http://www.manpagez.com/man/1/nice/) -- that is the way Mac/Linux handle telling the operating system how important a process is to you when it comes to allocating resources. In windows, the equivalent would be opening up the task manager and changing the process priority from Normal -> Low.

What you're doing here is basically telling the operating system you want to run this program in the background so when it asks for resources, give it less in case some foreground program wants them. This will of course make Foldit run slower, but that may be fine.

The normal way things happen is the OS will look at all of the programs and see if they have work they want to do. Foldit always has work to do so unless other programs have something to do, the OS will say "oh sure, you can use 100% CPU Foldit". Then when you try to interact with say you're browser, it will take a non-zero amount of time for your OS to figure out that you now want your browser to have priority and to scale back what it is letting Foldit do. This is what changing the priority does. It basically makes the OS more aware that it should be harsh and stingy with the CPU when it comes to Foldit.

--- Possible Bugs ---
The load should be heavily centered on the CPU. There shouldn't be much disk/network activity and the RAM usage should stay fairly steady.

If there is a lot of disk or network activity because of Foldit and that is causing your system to hang, that seems like it's a bug.

If the memory usage is continually rising out of control and that's causing the hangs while you're running tools, that would be a bug as well.

If when you are running no tools and you minimize Foldit the CPU usage doesn't go down (it should go down quite significantly) that seems like it would be a bug on the Mac (I've not noticed that ever happen on Windows or Linux).

--- Maxing out you CPU ---
The maxing out of a CPU core while a tool is running is how it should be happening (I'll talk a little more about this below). So even when you minimize, if a wiggle is still running, it will be eating up an entire core of your CPU.

If you want to know more about the maxing out of the CPU, I'll explain further below. If this explanation is too long/rambling/doesn't make sense feel free to ask for a shorter and different explanation.

So in most user applications, you tend to display some text/graphics and wait for input such as mouse clicks/keyboard entry. These are not very intensive, and you will see they may take 1% or less of your CPU when you're not interacting with them.

In the case of most 3D video games, the situation is different. One of the differences is we have a 'game loop'. The other difference is specific to Foldit where we are running tools. I'll go over them both separately.

--- Maxing out you CPU : The Game Loop ---
Because you are always displaying some sort of 3D environment that can continually change, you are doing lots of computations many times a second. What Foldit does here is we set a 'desired FPS' (frames per second). This is how many times we want the screen to update per second. The higher this value the smoother everything should look when things are animating. A higher value also means here is less time to preform all those calculations.

If your CPU is fast enough, you will get that many refreshes per second and the Foldit game loop will not use any more of your CPU here. If your CPU is not fast enough, it will max out at 100% trying to update your screen as fast as it can. Most of this work is only done if Foldit is visible. When you minimize Foldit, we pause doing things like drawing and updating what the protein looks like. This is why CPU usage will drop when you minimize Foldit.

Side Note: If you are interested in the high level game loop, see: http://gamedev.stackexchange.com/questions/1589/fixed-time-step-vs-variable-time-step
What Foldit does is basically attempt to set a fixed time step, but the code is flexible enough to fall back to a variable time step if the CPU can not keep up.

--- Maxing out you CPU : The Tools ---
This is probably what is causing the 'excessive cpu usage' that people are seeing. When you run wiggle, you are running rosetta code (http://boinc.bakerlab.org/) in a separate thread (http://en.wikipedia.org/wiki/Thread_(computing)). This will run as fast as it can and eat up 100% of at least one core on your CPU. If it is not, then it is waiting on something slow (such as accessing memory or disk or something else). On a system with 1 or 2 cores, this can be an issue if you are trying to run other programs. The same things happens if you are running a long calculation/macro in Excel and you try to do other things. The way rosetta code works, it would not really be feasible to change the code to try and run at 1/2 speed or something like that. We trust the operating system should be able to handle giving out resources in a manner that is transparent to the user (of course this doesn't always happen as you have experienced). That's why I pointed you in the direction of the nice/renice tools. The issue is with the operating system not releasing resources to the programs you want because it doesn't know that Foldit is less important than others.

Joined: 04/19/2009

I strongly suspect there is a bug.

I just had another system hang on puzzle 610. Client had protein dragged off screen, GIU hidden, and was minimized. It was fine for a couple hours then hung the system with this from the log.txt:

Autosaved puzzles/0000993271/0000099169/default/autosave.ir_solution.
Autosaved puzzles/0000993271/0000099169/default/autosave-best.ir_solution.
Autosaved puzzles/0000993271/0000099169/default/autosave-recentbest.ir_solution.
Autosaved puzzles/0000993271/0000099169/default/autosave-creditbest.ir_solution.
core.scoring.NeighborList: Minimization stats: 39 score/deriv cals, 10 narrow-from-wide updates, 1 full updates.
delta_score: -237.292
Playing sound: 3
Tool on_action_complete called
Tool on_action_complete called
Tool on_action_complete called
Error reading upload_tmp_988948_1291658941.ir_solution; expected SOLN, got ion:.

That is the end of the log.txt - nothing follows that line.

I had another hang earlier today on puzzle 607 but didn't grab the log.txt.

The only other things running on my computer with both hangs were Colloquy (external irc client) and FireFox (nothing with graphics or javascript or flash or anything graphical running).

I really wish that you all hadn't moved us all to the one true client. I had always backed clients up and dated them before you did that so I could roll back for comparisons. Today I wish that I had an older client kicking around - at least I'd be able to fold even if I couldn't score.

Joined: 04/19/2009

Somehow that code looked familiar...

http://fold.it/portal/node/989915

tamirh's picture
User offline. Last seen 6 years 18 weeks ago. Offline
Joined: 05/11/2012

Thanks for narrowing down the issue. This does seem like it's a bug separate from the 'excessive cpu usage' thing. I'll look into this and see if I can see what's up.

tamirh's picture
User offline. Last seen 6 years 18 weeks ago. Offline
Joined: 05/11/2012

Assigning to myself.

I'll try and figure out if this can be causing your hangs.

jamiexq's picture
User offline. Last seen 5 days 17 hours ago. Offline
Joined: 07/31/2011

This is happening with PC's too, not just Macs. And this has not always occurred. This has gotten worse in the last few weeks. It is so bad with my PC, maxing out the CPU using and overheating the machine within about 15 minutes. So bad I can hardly fold at all on the PC. Same PC I have been folding on for past year and just now having this problem. I am using same settings I have always used and minimizing does not help at all now. Something has definetely changed in the application.

Angus's picture
User offline. Last seen 1 day 3 hours ago. Offline
Joined: 06/04/2008
Groups: Beta Folders

Sorry, just not seeing that on Windows PC. Barely over 50% of a dual-core whn minimized and running heavy scripts.

It sounds like your fans and cooling situation need some attention. Any pc should be able to keep up with 100% CPU usage if the fans and heatsinks are kept clean and dust-free, and the vents are not obstructed.

infjamc's picture
User offline. Last seen 2 years 45 weeks ago. Offline
Joined: 02/20/2009
Groups: Contenders

In theory, that's true, but this was also an issue with my previous laptop... which could run any program at 100% CPU usage just fine, with Foldit being the sole exception. Until I upgraded to my current computer, the only way for me to play Foldit was to use third-party program to slow down the program by 15-30%.

tamirh's picture
User offline. Last seen 6 years 18 weeks ago. Offline
Joined: 05/11/2012

There are two reasons I can think of for this:

1) Not all work is created equally when it comes to circuits. I can max out my CPU by having a tight loop that does nothing but just goes on forever. While it will technically max out a CPU, the heat output will be much lower than 'real' work where more pathways on the core are actually being touched every instruction.

2) Foldit is a 3D video game that engages your GPU as well. While it's no Crysis and won't tax your video card to the max, the GPU can still output quite a bit of heat. If you have a dedicated video card on your laptop, they can run very hot.

On my personal laptop, I can run programs that max out my CPU and it will just get warm. If I play a game that taxes my video card, it gets blazingly hot (and if I haven't cleaned the fan or the vents are covered at all it will shut down to prevent heat damage).

spmm's picture
User offline. Last seen 40 weeks 6 days ago. Offline
Joined: 08/05/2010
Groups: Void Crushers

There is certainly a return to the 'not responding' and really really sluggish puzzle loading, saving and track changing which imo has been increasing in the last few updates (I'm running beta).

I run Win 7 Home Premium and foldit is really sluggish again on what are quite small puzzles. I am not skilled enough to comment on the thread counts and other issues reported elsewhere. It was quite zippy and yes I do keep my fans clean.

If it is necessary to run a modern i& Quad core CPU on 100% 24x7 to play the game then perhaps that should be mentioned in the marketing, so that people don't waste their time downloading it unless they are kitted up.

Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, RosettaCommons