3

(Ubuntu 14.04 server, 8 cores, 16GB RAM)

When running 3 scripts in parallel that utilise the same (other) script, the inverse of what I expect to happen occurs when "renice-ing" the processes as they are running.

Those with higher niceness - i.e. lower priority, use more CPU

Those with lower niceness - i.e. higher priority, use less CPU

enter image description here

It remains (pretty much) like this throughout execution. Any ideas? Have I fundamentally misunderstood what niceness is?

(I also tried renice-ing the parent scripts but it didn't seem to make a difference. sudo top had to be run to have permission to do all this.) (Also I think the times can be ignored, as 3167 was the second mgiza to be run by the parent - it originally had one with a lower PID)


Edit: All three of these processes are happy (and allowed) to go up to using 800% CPU!

9
  • 1
    You shouldn't ignore the TIME+, that's the total CPU time used. Clearly the higher priority processes have enjoyed a far higher share of CPU time, and are now chilling out. Finally the low priority process gets its day in the sun.
    – muru
    Apr 10, 2017 at 11:41
  • I understand what you mean but as I said, they are completely mispresentative; the shorter time for 3167 is because it had reached a later point in the parent script, and so was already on its second running of mgiza whereas the others were still on their first.
    – csey
    Apr 10, 2017 at 11:59
  • In that case, I'd look at the data and operating parameters - the high priority runs might have been more I/O bound (or waiting for some other such resource), instead of being CPU bound.
    – muru
    Apr 10, 2017 at 12:00
  • 1
    for that there's ionice
    – muru
    Apr 10, 2017 at 12:05
  • 1
    800% is wanted, as you have 8x100% total cpu available (8 cores). if it was amounting to less than than then some cpus would be idling. your -20 (low nice value, ie HIGHER priority) are enjoying some time off, while the 1st one is probably busy right now and takes the remaining cpu available (along with everything else currently running) Apr 10, 2017 at 12:11

1 Answer 1

2

It totally depends on what the processes are doing. A nice process is happy to let other processes past them in the run queue, but will still get 100% of the CPU (or however much it needs) if there is no other process that needs it at the moment.

3
  • Please see my edit!
    – csey
    Apr 10, 2017 at 12:01
  • Also - regardless of which process is given which value, or be the value -20, 0 or 19, consistently the inverse of what should happen with CPU allocation occurs with these processes.
    – csey
    Apr 10, 2017 at 12:36
  • @csey It may well be that the processes that have a higher priority run for less wall-clock time since they effectively have to wait for shorter amount of time in the run queue. This may give the perception that the use less CPU when viewed in top.
    – Kusalananda
    Apr 10, 2017 at 12:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .