Skip to content

Commit 67b2799

Browse files
Update how profiler enabled flag is checked (#4621)
Start to enable Cloud Profiler for clusterfuzz by using the flag in the project config yaml. This change is supported by a PR in clusterfuzz configs repo. In addition, remove profiler calls from fuzzer engines, since having it only in the bot startup is enough granularity.
1 parent 77ea427 commit 67b2799

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/clusterfuzz/_internal/bot/fuzzers/afl/launcher.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from clusterfuzz._internal.bot.fuzzers.afl.fuzzer import write_dummy_file
4444
from clusterfuzz._internal.fuzzing import strategy
4545
from clusterfuzz._internal.metrics import logs
46-
from clusterfuzz._internal.metrics import profiler
4746
from clusterfuzz._internal.platforms import android
4847
from clusterfuzz._internal.system import environment
4948
from clusterfuzz._internal.system import new_process
@@ -1661,7 +1660,6 @@ def main(argv):
16611660
# same python process.
16621661
logs.configure('run_fuzzer')
16631662
_verify_system_config()
1664-
profiler.start_if_needed('afl_launcher')
16651663

16661664
build_directory = environment.get_value('BUILD_DIR')
16671665
fuzzer_path = engine_common.find_fuzzer_path(build_directory, target_name)

src/clusterfuzz/_internal/bot/fuzzers/libFuzzer/engine.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from clusterfuzz._internal.bot.fuzzers.libFuzzer import stats
3030
from clusterfuzz._internal.fuzzing import strategy
3131
from clusterfuzz._internal.metrics import logs
32-
from clusterfuzz._internal.metrics import profiler
3332
from clusterfuzz._internal.system import environment
3433
from clusterfuzz._internal.system import shell
3534
from clusterfuzz.fuzz import engine
@@ -280,7 +279,6 @@ def fuzz(self, target_path, options, reproducers_dir, max_time):
280279
Returns:
281280
A FuzzResult object.
282281
"""
283-
profiler.start_if_needed('libfuzzer_fuzz')
284282
libfuzzer.set_sanitizer_options(target_path)
285283
runner = libfuzzer.get_runner(target_path)
286284

src/clusterfuzz/_internal/metrics/profiler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
# limitations under the License.
1414
"""Profiling functions."""
1515
from clusterfuzz._internal.base import utils
16+
from clusterfuzz._internal.config import local_config
1617
from clusterfuzz._internal.metrics import logs
1718
from clusterfuzz._internal.system import environment
1819

1920

2021
def start_if_needed(service):
21-
"""Start Google Cloud Profiler if |USE_PYTHON_PROFILER| environment variable
22-
is set."""
23-
if not environment.get_value('USE_PYTHON_PROFILER'):
22+
"""Start Google Cloud Profiler if profiling key in project config
23+
is enabled."""
24+
config = local_config.ProjectConfig()
25+
if not config.get('profiling.enabled', False):
2426
return True
2527

2628
project_id = utils.get_application_id()

0 commit comments

Comments
 (0)