fix: Java loop ID calculation and assertion transformer bug#1638
fix: Java loop ID calculation and assertion transformer bug#1638misrasaurabh1 merged 8 commits intoomni-javafrom
Conversation
Implemented CUDA-style loop ID calculation for performance mode:
- loopId = outerLoop * maxInnerIterations + innerIteration
- Behavior mode uses simple loop index (no inner iterations)
- Invocation ID simplified to call counter only
- Default CODEFLASH_INNER_ITERATIONS set to 10
Fixed critical bug in JavaAssertTransformer:
- Removed duplicate _special_re assignment that was missing parentheses
- Combined patterns into single regex: [\"'{}()]
- This fixes _find_balanced_parens and enables assertion transformation
Updated test expectations to match new marker format and loop ID calculation.
All 41 Java instrumentation tests passing.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| f'{indent}int _cf_loop{current_id} = Integer.parseInt(System.getenv("CODEFLASH_LOOP_INDEX"));', | ||
| f'{indent}int _cf_innerIterations{current_id} = Integer.parseInt(System.getenv().getOrDefault("CODEFLASH_INNER_ITERATIONS", "100"));', | ||
| f'{indent}int _cf_outerLoop{current_id} = Integer.parseInt(System.getenv("CODEFLASH_LOOP_INDEX"));', | ||
| f'{indent}int _cf_maxInnerIterations{current_id} = Integer.parseInt(System.getenv().getOrDefault("CODEFLASH_INNER_ITERATIONS", "10"));', |
There was a problem hiding this comment.
✅ Fixed in latest commit
| @@ -231,7 +236,7 @@ def _generate_sqlite_write_code( | |||
| f"{inner_indent} _cf_pstmt{iter_id}_{call_counter}.setString(3, _cf_test{iter_id});", | |||
There was a problem hiding this comment.
✅ Fixed in latest commit
PR Review SummaryPrek Checks✅ All checks pass — ruff check and ruff format both passed on changed files. Mypy
Code ReviewExisting comments: Both previous inline comments are already marked as ✅ Fixed. Re-review of latest changes — no critical bugs found. Specific observations:
Test CoverageMost changed files are new Java support files that don't exist on
Test results: 3159 passed, 58 skipped, 21 failed (all failures are pre-existing — tracer tests and a comparator test requiring Java runtime JAR not available in CI). Codeflash Optimization PRsNo optimization PRs are mergeable — all 13 open codeflash-ai[bot] PRs have failing CI checks (snyk limits, JS test failures, Windows test failures). Last updated: 2026-02-23 |
⚡️ Codeflash found optimizations for this PR📄 54% (0.54x) speedup for
|
In Java performance mode, loop IDs are calculated as: loopId = outerLoop * maxInnerIterations + innerIteration With 0-indexed inner iterations, this causes the max loop ID to end with 9 (e.g., 209, 299) when the actual total iteration count should be a round number (210, 300). This change adds +1 to the loop count when displaying for Java only, so that "299 loops" becomes "300 loops" to accurately reflect the total number of iterations run. Python loop counts remain unchanged as they use 1-based indexing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…o loop-id-calculation-fix-bug
⚡️ Codeflash found optimizations for this PR📄 13% (0.13x) speedup for
|
Changed iteration_id in performance mode markers to properly encode inner loop iterations for test case grouping: - Single call: iteration_id = innerIteration (0, 1, 2...) - Multiple calls: iteration_id = callId_innerIteration (1_0, 1_1, 2_0, 2_1...) This allows test results to be properly grouped by InvocationId, where each unique (call, inner_iteration) pair gets its own group for calculating minimum runtimes across outer loops. Fixed test expectations to match the new format. All 43 Java performance tests passing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…o loop-id-calculation-fix-bug
Implemented CUDA-style loop ID calculation for performance mode:
Fixed critical bug in JavaAssertTransformer:
Updated test expectations to match new marker format and loop ID calculation.
All 41 Java instrumentation tests passing.