From 7634f3f9496e65e701238407c3aa601e899648fd Mon Sep 17 00:00:00 2001 From: Cody Yu Date: Mon, 1 Feb 2021 22:42:10 +0000 Subject: [PATCH 1/4] [RPC] Replace timestamp with counter --- python/tvm/rpc/tracker.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/tvm/rpc/tracker.py b/python/tvm/rpc/tracker.py index 557c9ae24d40..ef7adcac2abb 100644 --- a/python/tvm/rpc/tracker.py +++ b/python/tvm/rpc/tracker.py @@ -42,7 +42,6 @@ # pylint: disable=invalid-name import heapq -import time import logging import socket import multiprocessing @@ -116,6 +115,7 @@ class PriorityScheduler(Scheduler): def __init__(self, key): self._key = key + self._request_cnt = 0 self._values = [] self._requests = [] @@ -134,7 +134,8 @@ def put(self, value): self._schedule() def request(self, user, priority, callback): - heapq.heappush(self._requests, (-priority, time.time(), callback)) + heapq.heappush(self._requests, (-priority, self._request_cnt, callback)) + self._request_cnt += 1 self._schedule() def remove(self, value): From cc26e403d3aa3332aa573d683187827ef1a164aa Mon Sep 17 00:00:00 2001 From: Cody Yu Date: Tue, 2 Feb 2021 17:36:50 +0000 Subject: [PATCH 2/4] add lock --- python/tvm/rpc/tracker.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/tvm/rpc/tracker.py b/python/tvm/rpc/tracker.py index ef7adcac2abb..6d53a084b738 100644 --- a/python/tvm/rpc/tracker.py +++ b/python/tvm/rpc/tracker.py @@ -44,6 +44,7 @@ import heapq import logging import socket +import threading import multiprocessing import errno import struct @@ -111,11 +112,12 @@ def summary(self): class PriorityScheduler(Scheduler): - """Priority based scheduler, FIFO based on time""" + """Priority based scheduler, FIFO""" def __init__(self, key): self._key = key self._request_cnt = 0 + self._lock = threading.Lock() self._values = [] self._requests = [] @@ -134,8 +136,9 @@ def put(self, value): self._schedule() def request(self, user, priority, callback): - heapq.heappush(self._requests, (-priority, self._request_cnt, callback)) - self._request_cnt += 1 + with self._lock: + heapq.heappush(self._requests, (-priority, self._request_cnt, callback)) + self._request_cnt += 1 self._schedule() def remove(self, value): From dcb9b893e50ce23afcfeaa8731fd85df42f77f8c Mon Sep 17 00:00:00 2001 From: Cody Yu Date: Tue, 2 Feb 2021 15:59:59 -0800 Subject: [PATCH 3/4] Update python/tvm/rpc/tracker.py --- python/tvm/rpc/tracker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tvm/rpc/tracker.py b/python/tvm/rpc/tracker.py index 6d53a084b738..e1c366e99b0d 100644 --- a/python/tvm/rpc/tracker.py +++ b/python/tvm/rpc/tracker.py @@ -112,7 +112,7 @@ def summary(self): class PriorityScheduler(Scheduler): - """Priority based scheduler, FIFO""" + """Priority based scheduler, FIFO based on request order""" def __init__(self, key): self._key = key From a5c704422fe9124fceb96f8a476d2b696a32b56c Mon Sep 17 00:00:00 2001 From: Cody Yu Date: Thu, 4 Feb 2021 18:39:05 +0000 Subject: [PATCH 4/4] trigger ci