echuraev commented on code in PR #13420:
URL: https://github.com/apache/tvm/pull/13420#discussion_r1027592851
##########
python/tvm/rpc/base.py:
##########
@@ -136,13 +139,30 @@ def random_key(prefix, cmap=None):
key : str
The generated random key
"""
- if cmap:
- while True:
- key = prefix + str(random.random())
- if key not in cmap:
- return key
- else:
- return prefix + str(random.random())
+ while True:
+ key = "{}{}{}".format(prefix, delimiter, random.random())
+ if not cmap or key not in cmap:
+ break
Review Comment:
Is it expected that if the `key` is found in `cmap` then on the next
iteration it contains more delimiters than only one?
E.g.:
- First iteration:
```
prefix = "127.0.0.1:5555"
key = "127.0.0.1:5555:123456"
```
`cmap` has already contained this key `127.0.0.1:5555:123456`. We will
iterate once again.
- Second iteration:
```
key = "127.0.0.1:5555:123456:654321"
```
If we split this key after the second iteration, then we get
`127.0.0.1:5555:123456` but it is not the key.
Probably this change will help us to avoid this problem?
```suggestion
key = "{}{}{}".format(prefix, delimiter, random.random())
if not cmap or key not in cmap:
break
delimiter = ""
```
Or maybe I missed something and everything should work?
##########
python/tvm/rpc/proxy.py:
##########
@@ -319,7 +319,7 @@ def _regenerate_server_keys(self, keys):
new_keys = []
# re-generate the server match key, so old information is invalidated.
for key in keys:
- rpc_key, _ = key.split(":")
+ rpc_key, _ = base.split_random_key(key)
handle = self._server_pool[key]
del self._server_pool[key]
new_key = base.random_key(rpc_key + ":", keyset)
Review Comment:
Should we also update this line? Because variable `keyset` is not on the
right place in the list of arguments and I expect that after first iteration we
will have something like that: `127.0.0.1:5555::123456`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]