summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-04-06 20:07:11 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-04-06 20:07:11 +0200
commit1338dda1c63dfd605ef41620e8a7b99f7a864d08 (patch)
treea88e02ede9c2799374b9af3ddf360b9ba6e22161
parente71f8ee4537e02de1663eac097fb66035ddff2c8 (diff)
downloadcython-1338dda1c63dfd605ef41620e8a7b99f7a864d08.tar.gz
Try if a random hash seed leads to a better sharding distribution in the test runner.
-rwxr-xr-xruntests.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/runtests.py b/runtests.py
index fe15a7c5b..f12fe38a9 100755
--- a/runtests.py
+++ b/runtests.py
@@ -3,6 +3,7 @@
from __future__ import print_function
import atexit
+import base64
import os
import sys
import re
@@ -1926,6 +1927,10 @@ class ShardExcludeSelector(object):
# This is an exclude selector so it can override the (include) selectors.
# It may not provide uniform distribution (in time or count), but is a
# determanistic partition of the tests which is important.
+
+ # Random seed to improve the hash distribution.
+ _seed = base64.b64decode(b'2ged1EtsGz/GkisJr22UcLeP6n9XIaA5Vby2wM49Wvg=')
+
def __init__(self, shard_num, shard_count):
self.shard_num = shard_num
self.shard_count = shard_count
@@ -1933,7 +1938,7 @@ class ShardExcludeSelector(object):
def __call__(self, testname, tags=None, _hash=zlib.crc32, _is_py2=IS_PY2):
# Cannot use simple hash() here as shard processes might use different hash seeds.
# CRC32 is fast and simple, but might return negative values in Py2.
- hashval = _hash(testname) & 0x7fffffff if _is_py2 else _hash(testname.encode())
+ hashval = _hash(self._seed + testname) & 0x7fffffff if _is_py2 else _hash(self._seed + testname.encode())
return hashval % self.shard_count != self.shard_num