Correctly nice and ionice the worker processes.

This had stopped working.
Unfortunately it doesn't seem to help anyway.
Ideally the responsiveness of the interface is the same, regardless
of whether the workers are paused or not. Atm its much better when
they are paused.
This commit is contained in:
Andrew Hamilton 2016-11-09 23:52:12 +01:00
parent ca33199456
commit 4b48c0c912
4 changed files with 5 additions and 18 deletions

View file

@ -6,7 +6,7 @@ set -e
echo "Install the dependencies of the vigil script..." echo "Install the dependencies of the vigil script..."
sudo apt-get --yes install python3-minimal python3-pygments python3-pyinotify \ sudo apt-get --yes install python3-minimal python3-pygments python3-pyinotify \
python3-urwid python3-psutil python3-docopt util-linux python3-urwid python3-docopt util-linux
echo echo
echo "Install all the tools vigil may need..." echo "Install all the tools vigil may need..."
./install-tools ./install-tools

2
vigil
View file

@ -918,7 +918,7 @@ def save_state(pickle_path, summary, screen, log):
def main(root_path, loop, worker_count=None, is_sandboxed=True, def main(root_path, loop, worker_count=None, is_sandboxed=True,
editor_command=None, is_being_tested=False): editor_command=None, is_being_tested=False):
if worker_count is None: if worker_count is None:
worker_count = multiprocessing.cpu_count() * 2 worker_count = multiprocessing.cpu_count()
pickle_path = os.path.join(tools.CACHE_PATH, "summary.pickle") pickle_path = os.path.join(tools.CACHE_PATH, "summary.pickle")
jobs_added_event = asyncio.Event() jobs_added_event = asyncio.Event()
appearance_changed_event = asyncio.Event() appearance_changed_event = asyncio.Event()

View file

@ -11,8 +11,6 @@ import shutil
import tempfile import tempfile
import unittest import unittest
import psutil
os.environ["TERM"] = "xterm-256color" os.environ["TERM"] = "xterm-256color"
import fill3 import fill3
@ -213,17 +211,12 @@ def _tmp_total():
return len(os.listdir("/tmp")) return len(os.listdir("/tmp"))
def _all_processes():
return set(psutil.process_iter())
class MainTestCase(unittest.TestCase): class MainTestCase(unittest.TestCase):
def test_main_and_restart_and_no_leaks_and_is_relocatable(self): def test_main_and_restart_and_no_leaks_and_is_relocatable(self):
def test_run(root_path, loop): def test_run(root_path, loop):
mount_total = _mount_total() mount_total = _mount_total()
# tmp_total = _tmp_total() # tmp_total = _tmp_total()
# processes = _all_processes()
foo_path = os.path.join(root_path, "foo") foo_path = os.path.join(root_path, "foo")
open(foo_path, "w").close() open(foo_path, "w").close()
vigil.manage_cache(root_path) vigil.manage_cache(root_path)
@ -236,7 +229,6 @@ class MainTestCase(unittest.TestCase):
self.assertTrue(os.path.exists(".vigil/" + file_name)) self.assertTrue(os.path.exists(".vigil/" + file_name))
self.assertEqual(_mount_total(), mount_total) self.assertEqual(_mount_total(), mount_total)
# self.assertEqual(_tmp_total(), tmp_total) # self.assertEqual(_tmp_total(), tmp_total)
# self.assertEqual(_all_processes(), processes) # Fix
temp_dir = tempfile.mkdtemp() temp_dir = tempfile.mkdtemp()
try: try:
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()

View file

@ -7,15 +7,11 @@ import asyncio
import os import os
import signal import signal
import psutil
import tools import tools
def _make_process_nicest(pid): def nice_command(command):
process = psutil.Process(pid) return ["nice", "-n", "19", "ionice", "-c", "3"] + command
process.nice(19)
process.ionice(psutil.IOPRIO_CLASS_IDLE)
class Worker: class Worker:
@ -37,7 +33,7 @@ class Worker:
else: else:
command = [__file__] command = [__file__]
create = asyncio.create_subprocess_exec( create = asyncio.create_subprocess_exec(
*command, stdin=asyncio.subprocess.PIPE, *nice_command(command), stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
preexec_fn=os.setsid) preexec_fn=os.setsid)
self.process = await create self.process = await create
@ -53,7 +49,6 @@ class Worker:
async def job_runner(self, summary, log, jobs_added_event, async def job_runner(self, summary, log, jobs_added_event,
appearance_changed_event): appearance_changed_event):
await self.create_process() await self.create_process()
_make_process_nicest(self.child_pgid)
while True: while True:
await jobs_added_event.wait() await jobs_added_event.wait()
while True: while True: