Skip to content

Commit

Permalink
Revert "Add GreenBench implementation (#1912)"
Browse files Browse the repository at this point in the history
This reverts commit c734a74.
  • Loading branch information
jonathanmetzman committed Dec 10, 2023
1 parent c734a74 commit cb95c7d
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 160 deletions.
16 changes: 0 additions & 16 deletions common/experiment_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,6 @@ def get_custom_seed_corpora_filestore_path():
'custom_seed_corpora')


def get_oss_fuzz_corpora_unarchived_path():
"""Returns path containing the user-provided seed corpora."""
return posixpath.join(get_experiment_filestore_path(),
'oss_fuzz_unarchived')


def get_random_corpora_filestore_path():
"""Returns path containing seed corpora for the target fuzzing experiment.""" # pylint: disable=line-too-long
return posixpath.join(get_experiment_filestore_path(), 'random_corpora')


def get_dispatcher_instance_name(experiment: str) -> str:
"""Returns a dispatcher instance name for an experiment."""
return f'd-{experiment}'
Expand Down Expand Up @@ -149,11 +138,6 @@ def is_local_experiment():
return bool(environment.get('LOCAL_EXPERIMENT'))


def is_micro_experiment():
"""Returns True if running a micro experiment."""
return bool(environment.get('MICRO_EXPERIMENT'))


def get_trial_dir(fuzzer, benchmark, trial_id):
"""Returns the unique directory for |fuzzer|, |benchmark|, and
|trial_id|."""
Expand Down
101 changes: 0 additions & 101 deletions common/random_corpus_fuzzing_utils.py

This file was deleted.

1 change: 0 additions & 1 deletion database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class Trial(Base):
# Columns used for preemptible experiments.
preemptible = Column(Boolean, default=False, nullable=False)
preempted = Column(Boolean, default=False, nullable=False)
trial_group_num = Column(Integer, nullable=True)

# Every trial has snapshots which is basically the saved state of that trial
# at a given time. The snapshots field here and the trial field on Snapshot,
Expand Down
11 changes: 2 additions & 9 deletions experiment/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import time
from typing import List

from common import random_corpus_fuzzing_utils
from common import experiment_path as exp_path
from common import experiment_utils
from common import logs
Expand Down Expand Up @@ -90,7 +89,7 @@ def _initialize_trials_in_db(trials: List[models.Trial]):
db_utils.bulk_save(trials)


class Experiment: # pylint: disable=too-many-instance-attributes
class Experiment:
"""Class representing an experiment."""

def __init__(self, experiment_config_filepath: str):
Expand All @@ -102,7 +101,6 @@ def __init__(self, experiment_config_filepath: str):
self.experiment_name = self.config['experiment']
self.git_hash = self.config['git_hash']
self.preemptible = self.config.get('preemptible_runners')
self.micro_experiment = self.config.get('micro_experiment')


def build_images_for_trials(fuzzers: List[str], benchmarks: List[str],
Expand All @@ -125,8 +123,7 @@ def build_images_for_trials(fuzzers: List[str], benchmarks: List[str],
models.Trial(fuzzer=fuzzer,
experiment=experiment_name,
benchmark=benchmark,
preemptible=preemptible,
trial_group_num=trial) for trial in range(num_trials)
preemptible=preemptible) for _ in range(num_trials)
]
trials.extend(fuzzer_benchmark_trials)
return trials
Expand All @@ -153,10 +150,6 @@ def dispatcher_main():
experiment.preemptible)
_initialize_trials_in_db(trials)

if experiment.micro_experiment:
random_corpus_fuzzing_utils.initialize_random_corpus_fuzzing(
experiment.benchmarks, experiment.num_trials)

create_work_subdirs(['experiment-folders', 'measurement-folders'])

# Start measurer and scheduler in seperate threads/processes.
Expand Down
2 changes: 0 additions & 2 deletions experiment/resources/runner-startup-script-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ docker run \
-e BENCHMARK={{benchmark}} \
-e EXPERIMENT={{experiment}} \
-e TRIAL_ID={{trial_id}} \
-e TRIAL_GROUP_NUM={{trial_group_num}} \
-e MICRO_EXPERIMENT={{micro_experiment}} \
-e MAX_TOTAL_TIME={{max_total_time}} \
-e SNAPSHOT_PERIOD={{snapshot_period}} \
-e NO_SEEDS={{no_seeds}} \
Expand Down
3 changes: 0 additions & 3 deletions experiment/run_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def _set_default_config_values(config: Dict[str, Union[int, str, bool]],
config['snapshot_period'] = config.get(
'snapshot_period', experiment_utils.DEFAULT_SNAPSHOT_SECONDS)
config['private'] = config.get('private', False)
config['micro_experiment'] = config.get('micro_experiment', False)


def _validate_config_parameters(
Expand Down Expand Up @@ -188,8 +187,6 @@ def read_and_validate_experiment_config(config_filename: str) -> Dict:
Requirement(False, int, False, ''),
'runner_memory':
Requirement(False, str, False, ''),
'micro_experiment':
Requirement(False, bool, False, ''),
}

all_params_valid = _validate_config_parameters(config, config_requirements)
Expand Down
16 changes: 1 addition & 15 deletions experiment/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ def get_clusterfuzz_seed_corpus_path(fuzz_target_path):
return seed_corpus_path if os.path.exists(seed_corpus_path) else None


def _unpack_random_corpus(corpus_directory):
shutil.rmtree(corpus_directory)

benchmark = environment.get('BENCHMARK')
trial_group_num = environment.get('TRIAL_GROUP_NUM', 0)
random_corpora_dir = experiment_utils.get_random_corpora_filestore_path()
random_corpora_sub_dir = f'trial-group-{int(trial_group_num)}'
random_corpus_dir = posixpath.join(random_corpora_dir, benchmark,
random_corpora_sub_dir)
filestore_utils.cp(random_corpus_dir, corpus_directory, recursive=True)


def _copy_custom_seed_corpus(corpus_directory):
"""Copy custom seed corpus provided by user"""
shutil.rmtree(corpus_directory)
Expand Down Expand Up @@ -269,9 +257,7 @@ def set_up_corpus_directories(self):
FUZZ_TARGET_DIR, fuzz_target_name)
input_corpus = environment.get('SEED_CORPUS_DIR')
os.makedirs(input_corpus, exist_ok=True)
if environment.get('MICRO_EXPERIMENT'):
_unpack_random_corpus(input_corpus)
elif not environment.get('CUSTOM_SEED_CORPUS_DIR'):
if not environment.get('CUSTOM_SEED_CORPUS_DIR'):
_unpack_clusterfuzz_seed_corpus(target_binary, input_corpus)
else:
_copy_custom_seed_corpus(input_corpus)
Expand Down
12 changes: 3 additions & 9 deletions experiment/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def start_trials(trials, experiment_config: dict, pool, core_allocation=None):
return started_trials


class TrialProxy: # pylint: disable=too-many-instance-attributes
class TrialProxy:
"""A proxy object for a model.Trial. TrialProxy's allow these fields to be
set and retreived without making any database calls."""

Expand All @@ -701,7 +701,6 @@ def __init__(self, trial):
self.time_ended = trial.time_ended
self.preemptible = trial.preemptible
self.cpuset = None
self.trial_group_num = trial.trial_group_num


def _initialize_logs(experiment):
Expand Down Expand Up @@ -730,7 +729,7 @@ def _start_trial(trial: TrialProxy, experiment_config: dict, cpuset=None):
logger.info('Start trial %d.', trial.id)
started = create_trial_instance(trial.fuzzer, trial.benchmark, trial.id,
experiment_config, trial.preemptible,
cpuset, trial.trial_group_num)
cpuset)
if started:
trial.time_started = datetime_now()
trial.cpuset = cpuset
Expand All @@ -744,7 +743,6 @@ def render_startup_script_template( # pylint: disable=too-many-arguments
fuzzer: str,
benchmark: str,
trial_id: int,
trial_group_num: int,
experiment_config: dict,
cpuset=None):
"""Render the startup script using the template and the parameters
Expand All @@ -762,8 +760,6 @@ def render_startup_script_template( # pylint: disable=too-many-arguments
'experiment': experiment,
'fuzzer': fuzzer,
'trial_id': trial_id,
'trial_group_num': trial_group_num,
'micro_experiment': experiment_config['micro_experiment'],
'max_total_time': experiment_config['max_total_time'],
'snapshot_period': experiment_config['snapshot_period'],
'experiment_filestore': experiment_config['experiment_filestore'],
Expand Down Expand Up @@ -794,15 +790,13 @@ def create_trial_instance( # pylint: disable=too-many-arguments
trial_id: int,
experiment_config: dict,
preemptible: bool,
cpuset=None,
trial_group_num: int = 0) -> bool:
cpuset=None) -> bool:
"""Create or start a trial instance for a specific
trial_id,fuzzer,benchmark."""
instance_name = experiment_utils.get_trial_instance_name(
experiment_config['experiment'], trial_id)
startup_script = render_startup_script_template(instance_name, fuzzer,
benchmark, trial_id,
trial_group_num,
experiment_config, cpuset)
startup_script_path = f'/tmp/{instance_name}-start-docker.sh'
with open(startup_script_path, 'w', encoding='utf-8') as file_handle:
Expand Down
1 change: 0 additions & 1 deletion experiment/test_data/experiment-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ measurers_cpus: null
runner_num_cpu_cores: 1
runner_machine_type: 'n1-standard-1'
private: false
micro_experiment: false
1 change: 0 additions & 1 deletion experiment/test_data/local-experiment-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ report_filestore: /tmp/web-reports
local_experiment: true
benchmarks: "benchmark-1,benchmark-2"
git_hash: "git-hash"
micro_experiment: false
2 changes: 0 additions & 2 deletions experiment/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ def test_create_trial_instance(benchmark, expected_image, expected_target,
-e BENCHMARK={benchmark} \\
-e EXPERIMENT=test-experiment \\
-e TRIAL_ID=9 \\
-e TRIAL_GROUP_NUM=0 \\
-e MICRO_EXPERIMENT=False \\
-e MAX_TOTAL_TIME=86400 \\
-e SNAPSHOT_PERIOD=900 \\
-e NO_SEEDS=False \\
Expand Down

0 comments on commit cb95c7d

Please sign in to comment.