Commit 14314ab3 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

[foozzie] Remove per-testcase random seed

We used the same random seed for all test cases of a fuzz session
for transitioning from choosing the flags on V8 side.

Since the grace period for stable bisection is over, we now use
the same random number generator throughout the fuzz session which
leads to a wider range of differently chosen flags.

TBR=tmrts@chromium.org

No-Try: true
Bug: chromium:813833
Change-Id: I07b9fe5de378c01344afd486bfd85fcbf0fcd8d2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1906377Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64910}
parent 4d1b7af7
......@@ -4,6 +4,7 @@
# found in the LICENSE file.
import os
import random
import subprocess
import sys
import unittest
......@@ -33,13 +34,10 @@ class ConfigTest(unittest.TestCase):
When experiment distribution changes this test might change, too.
"""
class Rng(object):
def random(self):
return 0.5
self.assertEqual(
[
'--first-config=ignition_no_ic',
'--second-config=ignition_turbo',
'--first-config=ignition',
'--second-config=ignition_turbo_opt',
'--second-d8=d8',
'--second-config-extra-flags=--stress-scavenge=100',
'--second-config-extra-flags=--no-regexp-tier-up',
......@@ -47,7 +45,7 @@ class ConfigTest(unittest.TestCase):
'--second-config-extra-flags=--no-enable-bmi2',
'--second-config-extra-flags=--no-enable-lzcnt',
],
v8_fuzz_config.Config('foo', Rng(), 42).choose_foozzie_flags(),
v8_fuzz_config.Config('foo', random.Random(42)).choose_foozzie_flags(),
)
......
......@@ -60,36 +60,26 @@ ADDITIONAL_FLAGS = [
]
class Config(object):
def __init__(self, name, rng=None, random_seed=None):
def __init__(self, name, rng=None):
"""
Args:
name: Name of the used fuzzer.
rng: Random number generator for generating experiments.
random_seed: Random-seed used for d8 throughout one fuzz session.
TODO(machenbach): Remove random_seed after a grace period of a couple of
days. We only have it to keep bisection stable. Afterwards we can just
use rng.
"""
self.name = name
self.rng = rng or random.Random()
self.random_seed = random_seed
def choose_foozzie_flags(self):
"""Randomly chooses a configuration from FOOZZIE_EXPERIMENTS.
Returns: List of flags to pass to v8_foozzie.py fuzz harness.
"""
# TODO(machenbach): Temporarily use same RNG state for all test cases in one
# fuzz session. See also TODO above.
if self.random_seed is not None:
flags_rng = random.Random(self.random_seed)
else:
flags_rng = random.Random()
# Add additional flags to second config based on experiment percentages.
extra_flags = []
for p, flag in ADDITIONAL_FLAGS:
if flags_rng.random() < p:
if self.rng.random() < p:
extra_flags.append('--second-config-extra-flags=%s' % flag)
# Calculate flags determining the experiment.
......
Markdown is supported
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