Skip to content

Commit

Permalink
remove artificial time blocks (#183)
Browse files Browse the repository at this point in the history
This change sets the time block to 0.01 when work is present, which is a
reasonable poller duration. The old blocks were used to capture work and
simualte a busy environment. While the old blocks we're by no means
slow, this change will imporve execution by an order of magnatude.

Signed-off-by: Kevin Carter <[email protected]>
  • Loading branch information
cloudnull authored Sep 10, 2021
1 parent 9cc55b5 commit 63ffc6d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions directord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def run_job(self, lock=None, sentinel=False):

self.bind_job = self.driver.job_connect()
poller_time = time.time()
poller_interval = 8
poller_interval = 1
cache_check_time = time.time()

# Ensure that the cache path exists before executing.
Expand Down Expand Up @@ -854,7 +854,7 @@ def run_job(self, lock=None, sentinel=False):
if self.driver.bind_check(
bind=self.bind_job, constant=poller_interval
):
poller_interval, poller_time = 8, time.time()
poller_interval, poller_time = 1, time.time()
(
_,
_,
Expand Down
8 changes: 4 additions & 4 deletions directord/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def run_job(self):
else:
self.return_jobs[job_id] = job_info

return 8, time.time()
return 1, time.time()

def run_interactions(self, sentinel=False):
"""Execute the interactions loop.
Expand All @@ -466,7 +466,7 @@ def run_interactions(self, sentinel=False):
self.bind_job = self.driver.job_bind()
self.bind_transfer = self.driver.transfer_bind()
poller_time = time.time()
poller_interval = 8
poller_interval = 1

while True:
current_time = time.time()
Expand All @@ -483,7 +483,7 @@ def run_interactions(self, sentinel=False):
if self.driver.bind_check(
bind=self.bind_transfer, constant=poller_interval
):
poller_interval, poller_time = 8, time.time()
poller_interval, poller_time = 1, time.time()

(
identity,
Expand Down Expand Up @@ -521,7 +521,7 @@ def run_interactions(self, sentinel=False):
elif self.driver.bind_check(
bind=self.bind_job, constant=poller_interval
):
poller_interval, poller_time = 8, time.time()
poller_interval, poller_time = 1, time.time()
(
identity,
msg_id,
Expand Down
2 changes: 1 addition & 1 deletion directord/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def test_run_job_run(self, mock_log_debug, mock_queue):
self.server.job_queue = mock_queue
self.server.workers = {b"test-node1": 12345, b"test-node2": 12345}
return_int, _ = self.server.run_job()
self.assertEqual(return_int, 8)
self.assertEqual(return_int, 1)
mock_log_debug.assert_called()
self.mock_driver.socket_send.assert_called()

Expand Down

0 comments on commit 63ffc6d

Please sign in to comment.