Skip to content

Commit

Permalink
[RPC] Replace timestamp with counter (apache#7389)
Browse files Browse the repository at this point in the history
  • Loading branch information
comaniac authored and Lokiiiiii committed Mar 1, 2021
1 parent 5fd225a commit f459ebb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions python/tvm/rpc/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
# pylint: disable=invalid-name

import heapq
import time
import logging
import socket
import threading
import multiprocessing
import errno
import struct
Expand Down Expand Up @@ -112,10 +112,12 @@ def summary(self):


class PriorityScheduler(Scheduler):
"""Priority based scheduler, FIFO based on time"""
"""Priority based scheduler, FIFO based on request order"""

def __init__(self, key):
self._key = key
self._request_cnt = 0
self._lock = threading.Lock()
self._values = []
self._requests = []

Expand All @@ -134,7 +136,9 @@ def put(self, value):
self._schedule()

def request(self, user, priority, callback):
heapq.heappush(self._requests, (-priority, time.time(), callback))
with self._lock:
heapq.heappush(self._requests, (-priority, self._request_cnt, callback))
self._request_cnt += 1
self._schedule()

def remove(self, value):
Expand Down

0 comments on commit f459ebb

Please sign in to comment.