Repository navigation
refactor: optimize cognitive complexity across workspace with llm-cc - #14
Conversation
9df72bd to
154b53a
Compare
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
154b53a to
1a3758f
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5eb2a9bfa8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Reduce overall repository cognitive complexity score by -5.52% (lmcc_per_token: 0.086455 -> 0.081680) and total cognitive complexity points by -5.60% (llm_cc: 4167.4 -> 3934.2) as measured by llm-cc on ROCm GPU. AST nesting levels reduced by 962 levels (-9.52%). Key improvements: - Use guard clauses and early returns to flatten nested match and if/else hierarchies - Extract inner loops into private helper functions (e.g. batch image processing, ONNX tensor normalization) - Replace manual coordinate indexing loops with idiomatic iterators (.pixels(), .enumerate_pixels()) - Deduplicate struct initialization in presets and model tables with const constructors - Retain exact public API contracts and 100% test pass rate
c83e9ce to
e94c8b2
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Since main's #14, CI builds and tests only in -c opt, so there is no separate fastbuild output tree.
…#17) * Make builds deterministic across output bases and tighten hermeticity Two clean builds of this commit in different checkouts and output bases now produce identical action keys and identical outputs for every spawn of `//...` and of the CI `-c opt` APK and WASM build, and the APKs and WASM are bit-for-bit identical. Before this, rav1e and av-scenechange were never cache hits on a fresh output base: their build scripts echo CARGO_ENCODED_RUSTFLAGS back as `cargo:rustc-env`, and that value carries `--remap-path-prefix=<exec_root>=.`. The rules_rust build-script runner shipped by rules_rs only redacts the exec root when a `/` or `\` follows it, so the per-action sandbox path leaked into `_bs.env`. A local patch also redacts it before `=`. The response-file bootstrap patch is dropped: the pinned rules_rs already includes the upstream fix (hermeticbuild/rules_rust#53), and without the patch process_wrapper is byte-identical across output bases and embeds no absolute paths. .bazelrc: - Disable sandbox networking. Every toolchain is downloaded and checksummed; the full `//...` and `-c opt` APK/WASM builds pass offline. - Never autodetect a host C/C++ toolchain; @llvm is the only one. - Sandbox persistent workers (Javac, Kotlin, Android tools), which otherwise run in the unsandboxed execroot. - Share a disk cache across checkouts and worktrees, garbage collected at 60G. Action keys are path-independent, so a fresh worktree reuses every other worktree's outputs. CI keeps using its output base and BuildBuddy. - CI: fail on a stale MODULE.bazel.lock and download only what each step inspects. Pipelined Rust compilation was measured and left off: on clean 24-core builds it was slower for both `//...` (110s vs 97s) and the `-c opt` APK/WASM build (184s vs 168s), since the builds are CPU-bound rather than critical-path-bound. * ci: request a larger BuildBuddy workflow VM The default Linux workflow VM (3 CPU, 8GB RAM, 20GB disk) ran out of disk in the -c opt APK step: the Android SDK/NDK, LLVM, Flutter and JDK repositories plus the fastbuild and opt output trees on a recycled runner exceed 20GB. More CPUs also shorten every remote-cache miss. Drop --remote_download_toplevel from the buildbuddy config: it is Bazel's default, and with --config=ci adding --remote_download_minimal it only produced a conflicting-expansion warning. * ci: describe the VM sizing for the single opt build step Since main's #14, CI builds and tests only in -c opt, so there is no separate fastbuild output tree.
Summary
This PR optimizes cognitive complexity across the Rust codebase in
razemifyusingllm-ccevaluated on AMD ROCm GPU (--backend rocm --gpu-layers -1) with default analysis settings.All public API contracts, behavioral guarantees, and unit tests are preserved (
cargo test --workspacepassing 100%).Key Results
lmcc_per_token):0.086455->0.081603(-5.61%)llm_cc):4167.4->3927.4(-240.0 points / -5.76%)comp_level):10,105->9,133(-972 levels / -9.62%)2,683->2,626(-57 branches)48,203->48,128(-75 tokens)Per-File Comparison
razemify-core/src/comic_pipeline.rsrazemify-cli/src/main.rsrazemify-core/src/rembg.rsxtask/src/cache.rsxtask/src/verify.rsrazemify-core/src/pipeline.rsrazemify-core/src/ffi.rsxtask/src/models.rsxtask/src/main.rsrazemify-core/src/flutter_ffi.rsxtask/src/wasm.rsImprovements & Refactoring Patterns
matchandif/elsestructures with early returns (let Ok(...) = ... else { return ... }), significantly reducing AST tree depth..pixels().map(...),.enumerate_pixels(), and.zip().ModelInfo { ... }inMODELS.Verification
cargo test --workspacepassed all 19 unit tests and doc-testsllm-cc --backend rocm --gpu-layers -1