|
17 | 17 | from scripts.cold_compile_performance._helpers.dense_project import write_dense_compile_project |
18 | 18 | from scripts.compile_performance_ratio._helpers.edit import apply_one_model_edit |
19 | 19 | from scripts.compile_performance_ratio.constants import ( |
| 20 | + ANALYSED_MODEL_COUNTERS, |
20 | 21 | ANALYSIS_CACHE_BYPASSES, |
21 | 22 | ANALYSIS_CACHE_MISSES, |
22 | 23 | BASE_GENERATOR_ENTRY, |
@@ -166,7 +167,7 @@ def compare_builds( |
166 | 167 | mode=mode, |
167 | 168 | compile_args=compile_args, |
168 | 169 | ) |
169 | | - check_cache_use(run=run, mode=mode) |
| 170 | + check_cache_use(run=run, mode=mode, models=models) |
170 | 171 | results[label].append(run) |
171 | 172 | if mode != COLD_MODE: |
172 | 173 | _, head_python, head_dir = builds[1] |
@@ -213,13 +214,21 @@ def _comparison( |
213 | 214 | ) |
214 | 215 |
|
215 | 216 |
|
216 | | -def check_cache_use(*, run: CompileRun, mode: str) -> None: |
217 | | - """Fail a bypassing run, a warm run with misses, or an edit run that analysed nothing.""" |
| 217 | +def check_cache_use(*, run: CompileRun, mode: str, models: int) -> None: |
| 218 | + """Fail a bypassing full compile, a warm run with misses, or an edit that analysed nothing.""" |
218 | 219 |
|
219 | 220 | misses: int | None = run.analysis_cache_misses |
220 | 221 | if misses is None or mode == COLD_MODE: |
221 | 222 | return |
222 | 223 | bypasses: int = run.analysis_cache_bypasses or 0 |
| 224 | + delta: bool = run.analysed_models is not None and run.analysed_models < models |
| 225 | + if mode == EDIT_MODE and delta: |
| 226 | + if misses + bypasses == 0: |
| 227 | + raise CompileComparisonError( |
| 228 | + f"{run.label} one-model edit delta compile analysed no model afresh, so the " |
| 229 | + "edit did not invalidate the edited model" |
| 230 | + ) |
| 231 | + return |
223 | 232 | if bypasses != 0: |
224 | 233 | raise CompileComparisonError( |
225 | 234 | f"{run.label} {mode} compile bypassed the analysis cache for {bypasses} models, so " |
@@ -328,6 +337,11 @@ def _compile_once( |
328 | 337 | timings_ms={name: value for name, value in numeric.items() if name in REPORTED_PHASES}, |
329 | 338 | analysis_cache_misses=numeric.get(ANALYSIS_CACHE_MISSES), |
330 | 339 | analysis_cache_bypasses=numeric.get(ANALYSIS_CACHE_BYPASSES), |
| 340 | + analysed_models=( |
| 341 | + sum(numeric[name] for name in ANALYSED_MODEL_COUNTERS) |
| 342 | + if all(name in numeric for name in ANALYSED_MODEL_COUNTERS) |
| 343 | + else None |
| 344 | + ), |
331 | 345 | report=json.dumps(payload, sort_keys=True), |
332 | 346 | ) |
333 | 347 |
|
|
0 commit comments