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

[DO NOT MERGE] Adding code for experiments using pubsub queues #2005

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

gustavogaldinoo
Copy link
Contributor

@gustavogaldinoo gustavogaldinoo commented Jul 25, 2024

This PR adds code to use pub sub queues on the measurer when running cloud experiments, instead of python in-memory queues.

This PR is still a draft, I still want to do some improvements on top of it, but I appreciate any feedback.

Will try to trigger a cloud experiment before adding reviewers to it.

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name measurer-pub-sub-test-experiment --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pub-sub-test-experiment --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pub-sub-test-experiment --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pub-sub-test-experiment-2 --fuzzers afl libfuzzer

Copy link
Contributor

@jonathanmetzman jonathanmetzman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a first pass. This looks like it's on the right path.

Copy link
Contributor

@DonggeLiu DonggeLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gustavogaldinoo : )

measure_manager_loop(experiment, max_total_time, measurers_cpus,
region_coverage)
cloud_project = experiment_config['cloud_project']
local_experiment = experiment_config['local_experiment']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use get() for both because the fields are not mandatory in the config file. E.g.,

cloud_project = experiment_config.get('cloud_project', '')
local_experiment = experiment_config.get('local_experiment', False)

if not local_experiment:
measure_manager = GoogleCloudMeasureManager(experiment, cloud_project,
region_coverage,
measurers_cpus)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to initialize the needed manager only? E.g.,

if local_experiment:
  measure_manager = LocalMeasureManager(...)
else:
  measure_manager = GoogleCloudMeasureManager(...)

"""Base class for measure manager. Encapsulates core methods that will be
implemented for Local and Google Cloud measure managers."""

def __init__(self, experiment: str, region_coverage=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Specify the type of region_coverage for consistency, given that experiment has type hinting.

"""Initialize and return request and response queues, respectively."""
raise NotImplementedError

def start_workers(self, request_queue, response_queue):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Given that some of the functions in the file have type-hinting, consider consistently doing so for the params and return types of this function and other functions in the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Dongge. I will try to type hint as much as possible.

I tried to do that at first, but I found a little hard to type hard the base class, as the types differ in each one of derived classes, so I chose to not type hint the base class, is that ok?

self.experiment = experiment

def initialize_queues(self):
"""Initialize and return request and response queues, respectively."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: """Initializes and returns ... for consistency. Same for other new functions in this PR.


return message.message.data

return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Personally, I would prefer to rule out the simple edge cases first:

if not response.received_messages:
  return None
....
return message.message.data

self.project_id = config['project_id']
self.experiment = config['experiment']
self.request_queue_subscription = f"""request-queue-subscription-
{self.experiment}"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Same as above

self.request_queue_subscription = (f'request-queue-subscription-
            {self.experiment}')

'name': self.subscription_path,
'topic': topic_path
})
logger.info(f'Subscription {subscription.name} created successfully.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Same question about lazy formatting, is that required?

trials: 20
max_total_time: 82800 # 23 hours, the default time for preemptible experiments.
trials: 3
max_total_time: 3660
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss-pushed debugging modifications?

@@ -16,6 +16,7 @@
"""Entrypoint for gcbrun into run_experiment. This script will get the command
from the last PR comment containing "/gcbrun" and pass it to run_experiment.py
which will run an experiment."""
# Dummy comment to trigger run experiment action
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss-pushed debugging modifications?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of that comment was just to be able to run gcbrun on the PR, I will remove those changes before merging it.

@jonathanmetzman
Copy link
Contributor

jonathanmetzman commented Aug 6, 2024

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name metzman-2024 --fuzzers afl libfuzzer

@jonathanmetzman
Copy link
Contributor

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name metzman-2024-2 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-1 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-2 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-3 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-4 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-5 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-6 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-7 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-8 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-10 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-11 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-12 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-14 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-15 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-16 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-17 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-18 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-19 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

/gcbrun run_experiment.py -a --experiment-config /opt/fuzzbench/service/experiment-config.yaml --benchmarks sqlite3_ossfuzz bloaty_fuzz_target --experiment-name pubsub-measurer-20 --fuzzers afl libfuzzer

@gustavogaldinoo
Copy link
Contributor Author

This PR is still a WIP.

In the experiments I've tried to run, it seems that we are having a problem in starting the measurer workers processes.

I couldn't debug to know the reason why this is happening.

As today is my last day at Google, am I afraid that I won't be able to debug any further and merge this PR so I am commenting to let you know that this is the current state of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants