Controlling system resources with nice and ionice
I'd like to run nodes with high priority for both cpu time and file i/o time. As found in roslaunch documentation, we can use a launch-prefix
to run nice
, like this example for rosserial
:
<node name="rosserial" pkg="rosserial_python" type="serial_node.py"
launch-prefix="nice -n -5 ionice -c2 -n0"
respawn="true" >
<param name="port" value="/dev/ttyS0" />
<param name="baud" value="115200" />
</node>
This works if I run nice -n 10
(or any nice value above 0), but requires superuser privileges if I want to increase the priority of the process using a negative nice value. However, this leads into a slew of nastiness with the superuser (e.g. rospy
not existing on the PYTHONPATH
), even if I use passwordless sudo.
Am I missing some typical way nice
is used to elevate process priorities in ROS?
I think the 'nicest' way to do something like this is to give the user
roslaunch
ing the capability to set process priorities / niceness, but that might be involved. You could try and see whethersudo -E
works.