Running large computations makes my computer lag

0

0

I am running a Java program which I wrote, which calls Gurobi (an optimization software for linear programs). When I am running a large program that takes ~20 hours to complete, even simple tasks (e.g. open a new tab in Chrome) takes 5-10 seconds. The java program which I wrote is a single threaded application, but Gurobi uses multiple cores. My computer is an iMac running OS X 10.7, which has 4 CPU cores.

I would like to be able to run large computations while still being able to do normal work on the computer.

Questions:

  1. How do I check which is the bottleneck: the CPU or the memory?
  2. Is it possible to make java run using a single CPU, so that the computer won't slow down dramatically?
  3. How do I reduce the impact of the large computations on the normal usability of the computer?

Update: I was able to get the large computations to run smoothly in the background by telling Gurobi to use only a single CPU core, and by using nice to give it low priority.

I Like to Code

Posted 2014-09-17T15:47:23.490

Reputation: 103

Have you confirmed that the CPU usage is actually your bottleneck? – Ƭᴇcʜιᴇ007 – 2014-09-17T15:52:16.910

It sounds like the real problem is likely Gurobi because your single threaded application isn't the reason for your performance problems. Unless you have evidence to say otherwise? – Ramhound – 2014-09-17T16:10:28.300

@Ƭᴇcʜιᴇ007 How do I determine which is the bottleneck? I put that in the question. – I Like to Code – 2014-09-17T16:30:11.183

Answers

2

First of all determine what the problem is. Is is actually a problem where Java/Gurobi hogs the CPU, or is the CPU fine and does it use almost all the memory? Or is it I/O bound?

If it is CPU bound check out the unix commands "nice" and "renice" or set the CPU affinity.

If it uses all the memory then try to configure Java to use less (or buy more RAM). (See this post on or sister site on how to do that).

If it is I/O-bound, then either give it its own disk (e.g. store the data on a second HDD or on a pen drive), speed up disk access (e.g. by using an SSD), or somehow set I/O priority. I have no idea how to do the latter on OSX.

Hennes

Posted 2014-09-17T15:47:23.490

Reputation: 60 739

1

First you should determine what the bottleneck is, you can use the OS Activity Monitor to look at system resource usage, and hopefully determine what is maxing out your usage and causing the slowdown.

For reducing CPU usage, there is a program on OS X called nice, which allows you to set the scheduling priority for the process. Try calling Gurobi with the command:

nice -n 20 Gurobi

Where Gurobi is the path to the executable for the program you are trying to run.

Setting -n 20 will set Gurobi to the lowest possible scheduling priority on your computer. It will cause the execution to take longer, but it will mean other processes will be more responsive. You can modify the value of -n to be between -20 and 20, where 20 is the lowest priority and -20 is the highest, so tweak it as you will.

Adam

Posted 2014-09-17T15:47:23.490

Reputation: 1 510