Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[infra] Match workers and jobs per core #13102

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion infra/cifuzz/actions/run_fuzzers/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ inputs:
required: false
default: False
parallel-fuzzing:
description: "Whether to use all available cores for fuzzing."
description: "How many cores to use cores for fuzzing. A specific number, True - all available cores or False to run single threaded on a single core."
required: false
default: false
output-sarif:
Expand Down
2 changes: 1 addition & 1 deletion infra/cifuzz/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self):
self.build_integration_path = (
constants.DEFAULT_EXTERNAL_BUILD_INTEGRATION_PATH)

self.parallel_fuzzing = environment.get_bool('PARALLEL_FUZZING', False)
self.parallel_fuzzing = environment.get('PARALLEL_FUZZING', False)
self.extra_environment_variables = _get_extra_environment_variables()
self.output_sarif = environment.get_bool('OUTPUT_SARIF', False)

Expand Down
2 changes: 1 addition & 1 deletion infra/cifuzz/external-actions/run_fuzzers/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ inputs:
required: false
default: False
parallel-fuzzing:
description: "Whether to use all available cores for fuzzing."
description: "How many cores to use cores for fuzzing. A specific number, True - all available cores or False to run single threaded on a single core."
required: false
default: false
output-sarif:
Expand Down
19 changes: 14 additions & 5 deletions infra/cifuzz/fuzz_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@
['testcase', 'stacktrace', 'corpus_path'])


def get_libfuzzer_parallel_options():
def get_libfuzzer_parallel_options(option):
"""Returns a list containing options to pass to libFuzzer to fuzz using all
available cores."""
return ['-jobs=' + str(multiprocessing.cpu_count())]
available or the specified number of cores."""
if option == 'true' or (isinstance(option, bool) and option == True):
cpu_count = str(multiprocessing.cpu_count())
else:
cpu_count = option
return [f'-jobs={cpu_count}', f'-workers={cpu_count}']


class ReproduceError(Exception):
Expand Down Expand Up @@ -189,13 +193,18 @@ def fuzz(self, batch=False) -> Optional[FuzzResult]:
if not self.config.report_ooms:
options.arguments.extend(LIBFUZZER_OPTIONS_NO_REPORT_OOM)

if self.config.parallel_fuzzing:
if (self.config.parallel_fuzzing == 'true' or
(isinstance(self.config.parallel_fuzzing, int) and
not isinstance(self.config.parallel_fuzzing, bool)) or
(isinstance(self.config.parallel_fuzzing, bool) and
self.config.parallel_fuzzing == True)):
if self.config.sanitizer == 'memory':
# TODO(https://github.com/google/oss-fuzz/issues/11915): Don't gate
# this after jobs is fixed for MSAN.
logging.info('Not using jobs because it breaks MSAN.')
else:
options.arguments.extend(get_libfuzzer_parallel_options())
options.arguments.extend(
get_libfuzzer_parallel_options(self.config.parallel_fuzzing))

result = engine_impl.fuzz(self.target_path, options, artifacts_dir,
self.duration)
Expand Down
Loading