[test] Add stress deopt to num fuzzer

Bug: v8:6917
Change-Id: I9f23515de0a1ae89babe41a42ab37fb2dfb67b48
Reviewed-on: https://chromium-review.googlesource.com/876324
Commit-Queue: Michał Majewski <majeski@google.com>
Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50767}
This commit is contained in:
Michal Majewski 2018-01-22 16:33:05 +01:00 committed by Commit Bot
parent 021f02b579
commit b5e6a1517e
2 changed files with 70 additions and 9 deletions

View File

@ -87,6 +87,12 @@ class NumFuzzer(base_runner.BaseTestRunner):
parser.add_option("--stress-gc", default=0, type="int",
help="probability [0-10] of adding --random-gc-interval "
"flag to the test")
parser.add_option("--stress-deopt", default=0, type="int",
help="probability [0-10] of adding --deopt-every-n-times "
"flag to the test")
parser.add_option("--stress-deopt-min", default=1, type="int",
help="extends --stress-deopt to have minimum interval "
"between deopt points")
parser.add_option("--tests-count", default=5, type="int",
help="Number of tests to generate from each base test")
@ -199,14 +205,21 @@ class NumFuzzer(base_runner.BaseTestRunner):
def _load_tests(self, options, suites, ctx):
# Find available test suites and read test cases from them.
deopt_fuzzer = bool(options.stress_deopt)
gc_stress = bool(options.stress_gc)
gc_fuzzer = bool(max([options.stress_marking,
options.stress_scavenge,
options.stress_compaction,
options.stress_gc]))
variables = {
"arch": self.build_config.arch,
"asan": self.build_config.asan,
"byteorder": sys.byteorder,
"dcheck_always_on": self.build_config.dcheck_always_on,
"deopt_fuzzer": False,
"gc_fuzzer": True,
"gc_stress": True,
"deopt_fuzzer": deopt_fuzzer,
"gc_fuzzer": gc_fuzzer,
"gc_stress": gc_stress,
"gcov_coverage": self.build_config.gcov_coverage,
"isolates": options.isolates,
"mode": self.mode_options.status_mode,
@ -246,6 +259,9 @@ class NumFuzzer(base_runner.BaseTestRunner):
fuzzers.append(fuzzer.create_scavenge_config(options.stress_scavenge))
if options.stress_gc:
fuzzers.append(fuzzer.create_gc_interval_config(options.stress_gc))
if options.stress_deopt:
fuzzers.append(fuzzer.create_deopt_config(options.stress_deopt,
options.stress_deopt_min))
return fuzzers
def _create_rerun_proc(self, options):

View File

@ -32,7 +32,14 @@ class Analyzer(object):
class Fuzzer(object):
def create_flags_generator(self, test, analysis_value):
def create_flags_generator(self, rng, test, analysis_value):
"""
Args:
rng: random number generator
test: test for which to create flags
analysis_value: value returned by the analyzer. None if there is no
corresponding analyzer to this fuzzer
"""
raise NotImplementedError()
@ -109,7 +116,7 @@ class FuzzerProc(base.TestProcProducer):
# Skip fuzzer for this test since it doesn't have analysis data
continue
p = fuzzer_config.probability
flag_gen = fuzzer_config.fuzzer.create_flags_generator(test,
flag_gen = fuzzer_config.fuzzer.create_flags_generator(self._rng, test,
analysis_value)
indexes += [len(gens)] * p
gens.append((p, flag_gen))
@ -163,6 +170,10 @@ def create_gc_interval_config(probability):
def create_compaction_config(probability):
return FuzzerConfig(probability, None, CompactionFuzzer())
def create_deopt_config(probability, min_interval):
return FuzzerConfig(probability, DeoptAnalyzer(min_interval),
DeoptFuzzer(min_interval))
class ScavengeAnalyzer(Analyzer):
def get_analysis_flags(self):
@ -175,7 +186,7 @@ class ScavengeAnalyzer(Analyzer):
class ScavengeFuzzer(Fuzzer):
def create_flags_generator(self, test, analysis_value):
def create_flags_generator(self, rng, test, analysis_value):
while True:
yield ['--stress-scavenge=%d' % analysis_value]
@ -191,7 +202,7 @@ class MarkingAnalyzer(Analyzer):
class MarkingFuzzer(Fuzzer):
def create_flags_generator(self, test, analysis_value):
def create_flags_generator(self, rng, test, analysis_value):
while True:
yield ['--stress-marking=%d' % analysis_value]
@ -207,13 +218,47 @@ class GcIntervalAnalyzer(Analyzer):
class GcIntervalFuzzer(Fuzzer):
def create_flags_generator(self, test, analysis_value):
def create_flags_generator(self, rng, test, analysis_value):
value = analysis_value / 10
while True:
yield ['--random-gc-interval=%d' % value]
class CompactionFuzzer(Fuzzer):
def create_flags_generator(self, test, analysis_value):
def create_flags_generator(self, rng, test, analysis_value):
while True:
yield ['--stress-compaction-random']
class DeoptAnalyzer(Analyzer):
MAX_DEOPT=1000000000
def __init__(self, min_interval):
super(DeoptAnalyzer, self).__init__()
self._min = min_interval
def get_analysis_flags(self):
return ['--deopt-every-n-times=%d' % self.MAX_DEOPT,
'--print-deopt-stress']
def do_analysis(self, result):
for line in reversed(result.output.stdout.splitlines()):
if line.startswith('=== Stress deopt counter: '):
counter = self.MAX_DEOPT - int(line.split(' ')[-1])
if counter < self._min:
# Skip this test since we won't generate any meaningful interval with
# given minimum.
return None
return counter
class DeoptFuzzer(Fuzzer):
def __init__(self, min_interval):
super(DeoptFuzzer, self).__init__()
self._min = min_interval
def create_flags_generator(self, rng, test, analysis_value):
while True:
value = analysis_value / 2
interval = rng.randint(self._min, max(value, self._min))
yield ['--deopt-every-n-times=%d' % interval]