Skip to content

Commit 1eb674d

Browse files
Merge pull request #181 from codeflash-ai/increase-noise-floor
Tracer bugs + increase perf noise floor for very small timings
2 parents 1d2bbf7 + 3cb6cb0 commit 1eb674d

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

codeflash/discovery/functions_to_optimize.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ def get_all_replay_test_functions(
288288
function = function_name
289289
file_path_parts = module_path_parts
290290
file_path = Path(project_root_path, *file_path_parts).with_suffix(".py")
291+
if not file_path.exists():
292+
continue
291293
file_to_functions_map[file_path].append((function, function_name, class_name))
292294
for file_path, functions in file_to_functions_map.items():
293295
all_valid_functions: dict[Path, list[FunctionToOptimize]] = find_all_functions_in_file(file_path=file_path)
@@ -389,13 +391,12 @@ def visit_ClassDef(self, node: ast.ClassDef) -> None:
389391

390392
def inspect_top_level_functions_or_methods(
391393
file_name: Path, function_or_method_name: str, class_name: str | None = None, line_no: int | None = None
392-
) -> FunctionProperties:
394+
) -> FunctionProperties | None:
393395
with open(file_name, encoding="utf8") as file:
394396
try:
395397
ast_module = ast.parse(file.read())
396-
except Exception as e:
397-
logger.exception(e)
398-
return False
398+
except Exception:
399+
return None
399400
visitor = TopLevelFunctionOrMethodVisitor(
400401
file_name=file_name, function_or_method_name=function_or_method_name, class_name=class_name, line_no=line_no
401402
)

codeflash/result/critic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def speedup_critic(
3232
The noise floor is doubled when benchmarking on a (noisy) GitHub Action virtual instance, also we want to be more confident there.
3333
"""
3434
in_github_actions_mode = bool(env_utils.get_pr_number())
35-
noise_floor = 2 * MIN_IMPROVEMENT_THRESHOLD if original_code_runtime < 10000 else MIN_IMPROVEMENT_THRESHOLD
35+
noise_floor = 3 * MIN_IMPROVEMENT_THRESHOLD if original_code_runtime < 10000 else MIN_IMPROVEMENT_THRESHOLD
3636
if in_github_actions_mode:
3737
noise_floor = noise_floor * 2 # Increase the noise floor in GitHub Actions mode
3838

codeflash/tracing/replay_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def create_trace_replay_test(
5050
"""
5151

5252
# TODO: Module can have "-" character if the module-root is ".". Need to handle that case
53-
function_properties: list[FunctionProperties] = [
53+
function_properties: list[FunctionProperties | None] = [
5454
inspect_top_level_functions_or_methods(
5555
file_name=function.file_name,
5656
function_or_method_name=function.function_name,
@@ -61,6 +61,8 @@ def create_trace_replay_test(
6161
]
6262
function_imports = []
6363
for function, function_property in zip(functions, function_properties):
64+
if function_property is None:
65+
continue
6466
if not function_property.is_top_level:
6567
# can't be imported and run in the replay test
6668
continue
@@ -110,6 +112,8 @@ def create_trace_replay_test(
110112
test_template = ""
111113
self = ""
112114
for func, func_property in zip(functions, function_properties):
115+
if func_property is None:
116+
continue
113117
if not func_property.is_top_level:
114118
# can't be imported and run in the replay test
115119
continue

0 commit comments

Comments
 (0)