Michael
Michael

Reputation: 5939

How to prevent compiler & linker from taking over entire machine?

When I compile a large project the compiler slows down the machine tremendously, virtually freezes it out. If I'm lucky a keystroke in vim takes a few seconds to register. If I'm not I may as well go for a walk since nothing can be done on my workstation at all.

Is there any way to prevent compiler and linker from consuming the entire machine? More generally, is it possible to limit a family of processes to a portion of computing resources, such as threads, memory, disk access bandwidth?

Something like limiting the resources available to the process tree that originates from the shell that runs the build would be ideal.

Upvotes: 1

Views: 88

Answers (2)

Johnride
Johnride

Reputation: 8746

I'm not an expert about it but you could try starting the compilation with a specific cgroup that has limited resources. I don't know exactly how complicated it is to do it but it shouldn't be too hard.

You could also try changing the nice of the process to give it a lower priority so that it does take the entire machine but will be easily bumped by another process.

Upvotes: 1

David Carpenter
David Carpenter

Reputation: 1680

Most linux distros have a package called cpulimit. You can use this to limit the CPU usage for the gcc tool chain binaries.

It's mention as an answer to this question.

Limiting certain processes to CPU % - Linux

Upvotes: 3

Related Questions