[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/+/1906377
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64910}
This commit is contained in:
Michael Achenbach 2019-11-10 16:34:31 +01:00 committed by Commit Bot
parent 4d1b7af7b1
commit 14314ab3c7
2 changed files with 6 additions and 18 deletions

View File

@ -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(),
)

View File

@ -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.