Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RPC] Replace timestamp with counter #7389

Merged
merged 4 commits into from
Feb 5, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"""
comaniac marked this conversation as resolved.
Show resolved Hide resolved

comaniac marked this conversation as resolved.
Show resolved Hide resolved
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