You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🔴 KeyError risk — Lines 91, 100, 109: Direct access r1['reg_spill_count'], r1['mean_s'], r3['reg_spill_count'] etc. If any benchmark dict misses a key, script crashes. Use .get() with a sensible default (e.g., r1.get('reg_spill_count', '?')).
🔴 Missing file existence check — Line 108: cnn_default = "models/graph/cnn.onnx" is hardcoded and never checked. If the file does not exist, bench_cnn.run_bench will likely raise a file-not-found error. Add os.path.exists(cnn_default) check and print a clear error message before running.
🟡 Inconsistent dict access — Lines 91-112: Mix of r1['key'] and r1.get('valid'). Unify to .get() for all fields to avoid silent failures and improve readability.
🟡 Timestamp inconsistency — _make_html and _make_markdown each call datetime.datetime.now().isoformat() independently. Compute the timestamp once in main() and pass it to both generators for report consistency.
💭 Typo — Line 107: Comment says "Comparation" instead of "Comparison". Minor but could be confusing.
📁 benchmarks/test_regalloc/bench_simple.py
🔴 Bug: Inconsistent uses in _gen_block — Lines 32-44: In the if i < num_vregs branch, uses includes dst (since src1/src2 are chosen from a pool that contains dst), but the else branch explicitly subtracts dst. This inconsistency may cause the allocator to treat an instruction as using a register it defines, which could lead to incorrect live-interval computation or unexpected spills.
Suggestion: Unify the logic — either always exclude dst from uses, or document why the first branch intentionally includes it.
🟡 Fragile private access — Line 49: len(alloc._spill_slots) accesses a private attribute. If the allocator’s internals change, this benchmark breaks.
Suggestion: Add a public property spill_count to LinearScanAllocator and use that.
🟡 Redundant duplicate stats — Lines 58-59: Both spills and reg_spill_count are set to spill_counts[-1].
Suggestion: Keep only one field; the duplicate adds confusion.
🟡 Inconsistent spill source — bench_allocate runs a final allocation after the loop (line 52) but uses spill_counts[-1] from the loop for the returned spills. Since the block is deterministic, they match, but this is fragile if randomness is introduced later.
Suggestion: Use the final run’s spill count for consistency, or remove the extra run.
💭 Nit: # flake8: noqa — Line 1 disables all linting for the file, masking potential style or unused-import issues.
Suggestion: Remove it and fix any actual lint warnings.
💭 Nit: _gen_block self-use — For i=0, the instruction v0 = v0 + v0 is generated. This is a valid test case, but it’s not obvious from the code; consider a comment.
💭 Nit: Benchmark stats — The function returns _alloc and _report dicts, which expose internals and may be unnecessary for a benchmark. If they’re only for debugging, consider removing them from the public return.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
依据设计文档,设计了三个Benchmark:
可能的问题:
Benchmark是基于v1.3的寄存器分配算法设计(PR#37),但是目前PR还未合并到主线