Unverified Commit 4e998f18 authored by Loïc Dachary's avatar Loïc Dachary
Browse files

do not randomize the seq/rand ratio

parent 1feebfbf
......@@ -520,16 +520,16 @@ class Reader(object):
return objects_count, bytes_read
def reader(args, image):
def reader(args, image, pattern):
reader = Reader(args, image)
reader.init()
if random.random() * 100 < args.rand_ratio:
if pattern == "rand":
(objects_count, bytes_read, too_long) = reader.read_rand()
else:
too_long = None
(objects_count, bytes_read) = reader.read_seq()
reader.uninit()
return (image, objects_count, bytes_read, too_long)
return (image, objects_count, bytes_read, too_long, pattern)
class Bench(object):
......@@ -589,9 +589,12 @@ class Bench(object):
logging.warning("Bench.ro_loop: running")
self.readers = set()
pending_readers = ["seq"] * (self.args.ro_workers - self.args.rand_ratio) + [
"rand"
] * self.args.rand_ratio
def create_reader():
return loop.run_in_executor(executor, reader, self.args, random.choice(self.images))
def create_reader(pattern):
return loop.run_in_executor(executor, reader, self.args, random.choice(self.images), pattern)
while not finished.is_set():
......@@ -599,13 +602,15 @@ class Bench(object):
await asyncio.sleep(1)
continue
while len(self.readers) < self.args.ro_workers:
self.readers.add(create_reader())
for pattern in pending_readers:
self.readers.add(create_reader(pattern))
pending_readers = []
logging.debug(f"Bench.ro_loop: waiting on {len(self.readers)} readers")
done, self.readers = await asyncio.wait(self.readers, return_when=asyncio.FIRST_COMPLETED)
for task in done:
(image, objects, size, too_long) = task.result()
(image, objects, size, too_long, pattern) = task.result()
pending_readers.append(pattern)
logging.debug(f"Bench.ro_loop: {image} {objects} objects, {size} bytes")
self.stats["object_read_count"] += objects
self.stats["bytes_read"] += size
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment