ad5b6d7dcb
Testrunner runs variants of a test sequentially without taking sharding into account. A slow test with slow variants slows down the whole test run no matter the sharding configuration. This CL implements a test hashing algorithm and variant sharding for test variants. R=machenbach@chromium.org CC=yangguo@chromium.org,sergiyb@chromium.org Bug: v8:8174 Change-Id: I15f8c547fa2f361fb6c53bf8d5df055d3df38d3e Reviewed-on: https://chromium-review.googlesource.com/c/1458016 Commit-Queue: Tamer Tas <tmrts@chromium.org> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#59530}
39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
# Copyright 2018 the V8 project authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
from . import base
|
|
|
|
|
|
# Alphabet size determines the hashing radix. Choosing a prime number prevents
|
|
# clustering of the hashes.
|
|
HASHING_ALPHABET_SIZE = 2 ** 7 -1
|
|
|
|
def radix_hash(capacity, key):
|
|
h = 0
|
|
for character in key:
|
|
h = (h * HASHING_ALPHABET_SIZE + ord(character)) % capacity
|
|
|
|
return h
|
|
|
|
|
|
class ShardProc(base.TestProcFilter):
|
|
"""Processor distributing tests between shards.
|
|
It hashes the unique test identifiers uses the hash to shard tests.
|
|
"""
|
|
def __init__(self, myid, shards_count):
|
|
"""
|
|
Args:
|
|
myid: id of the shard within [0; shards_count - 1]
|
|
shards_count: number of shards
|
|
"""
|
|
super(ShardProc, self).__init__()
|
|
|
|
assert myid >= 0 and myid < shards_count
|
|
|
|
self._myid = myid
|
|
self._shards_count = shards_count
|
|
|
|
def _filter(self, test):
|
|
return self._myid != radix_hash(self._shards_count, test.procid)
|