7

I need to run some long and heavy commands but at the same time I'd like to keep my desktop system responsive. Examples: btrfs deduplication, btrfs balance, etc. I don't mind if such commands take longer to finish if I give them a lower priority, but my system should be responsive at all times. Using nice -n 19 and ionice -c 3 should solve my problem, but I'm not sure which command should come first for maximum benefit.

Option A:

# nice -n 19 ionice -c 3 btrfs balance start --full-balance /

Option B:

# ionice -c 3 nice -n 19 btrfs balance start --full-balance /

Is there some subtle difference between options A and B? Are they equivalent perhaps?

  • 3
    It would only make a difference if ionice were very computational, or nice did lots of I/O. Neither is true. – Barmar Sep 5 '17 at 17:21
  • @Barmar: If you create an answer based on your comment I'll accept it. Thank you. – Francesco Turco Sep 6 '17 at 9:56
12

If nice caused lots of I/O, you would want to do:

ionice -c 3 nice ...

so that the impact of the I/O would be minimized.

Conversely, if ionice performed lots of computation, you would want to do

nice -n 19 ionice ...

to minimize its CPU impact.

But neither of these is true, they're both very simple commands (they just make a system call to change a process parameter, then execute the command). So the difference should be negligible.

And just to be complete, if both were true, you can't really win -- the impact of one of them can't be reduced.

| improve this answer | |
2

There is no practical difference between the two.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.