Skip to content

fix looping with JS/TS#1764

Merged
Saga4 merged 3 commits intomainfrom
fix/js-vitest-benchmarking-and-mocha-cjs
Mar 4, 2026
Merged

fix looping with JS/TS#1764
Saga4 merged 3 commits intomainfrom
fix/js-vitest-benchmarking-and-mocha-cjs

Conversation

@Saga4
Copy link
Contributor

@Saga4 Saga4 commented Mar 4, 2026

No description provided.

@claude
Copy link
Contributor

claude bot commented Mar 4, 2026

Claude finished @Saga4's task in 5m 6s —— View job


PR Review Summary

  • Triage PR scope
  • Run linting and type checks
  • Resolve stale review threads
  • Review code changes
  • Duplicate detection
  • Test coverage analysis
  • Optimization PRs handled

Prek Checks

All checks passed. No linting or formatting issues were found. The 65 mypy errors present across the changed files are pre-existing and not introduced by this PR.

Code Review

The PR addresses two real problems with JS/TS benchmarking: stdout pipe backpressure from excessive loop iterations, and inadequate subprocess timeouts for slow JS toolchains.

JS_BENCHMARKING_MAX_LOOPS: 100k → 5k (support.py)

The rationale is well-explained in the comment: 100k iterations × ~200 bytes/marker = 20–200 MB of stdout, creating pipe backpressure that inflated wall-clock time past the subprocess timeout. 5k is a reasonable reduction that still provides stable timing data.

Timeout formula (vitest_runner.py:622, test_runner.py:1033, mocha_runner.py:541)

Old: max(120, (target_duration_ms // 1000) + 60, timeout or 120)
New: max(120, (target_duration_ms // 1000) + 120, (timeout or 60) * 5)

In production, timeout=INDIVIDUAL_TESTCASE_TIMEOUT=15 is always passed, so:

  • The (timeout or 60) * 5 term evaluates to 15 * 5 = 75, which falls below the floor of 120 and has no effect
  • The effective change is just + 60 → + 120 in the second term (more headroom for startup)

The (timeout or 60) * 5 sub-expression is confusing since it has no practical effect with the actual caller values. A simpler formula like max(300, (target_duration_ms // 1000) + 120) would be clearer and more directly achieve the stated goal (comparable to behavioral tests at 600s). Fix this →

get_src_code fallback (models.py:775-782)

When libcst.parse_module fails (JS/TS files), instead of returning None, the PR returns a descriptive comment stub. The intent is good — code repair gets some context instead of nothing.

However, test_src is already read at line 773 before the cst.parse_module call fails. Returning test_src directly would give the code repair API the actual test content:

try:
    test_src = test_path.read_text(encoding="utf-8")
except Exception:
    return None

try:
    module_node = cst.parse_module(test_src)
except Exception:
    return test_src  # JS/TS: libcst can't parse, return raw source

The current approach returns only metadata (function name, file name), not the actual test body, which limits the usefulness for code repair. Fix this →

Duplicate Detection

The identical total_timeout formula is repeated verbatim in all three benchmarking runners (vitest_runner.py, test_runner.py, mocha_runner.py). This is pre-existing duplication (not introduced by this PR), but extracting it to a shared helper in support.py would be a worthwhile follow-up.

No other duplicates detected.

Test Coverage

All 23 dispatch tests pass. Coverage is low (~7–13%) for the runner files due to integration dependencies (Node.js runtimes), which is expected. The test update in test_support_dispatch.py correctly reflects the max_loops constant change.

Optimization PRs


@Saga4 Saga4 merged commit c9f506b into main Mar 4, 2026
9 of 26 checks passed
@Saga4 Saga4 deleted the fix/js-vitest-benchmarking-and-mocha-cjs branch March 4, 2026 05:39
KRRT7 added a commit that referenced this pull request Mar 4, 2026
PR #1764 changed JS_BENCHMARKING_MAX_LOOPS from 100_000 to 1_000 but
the test was updated to assert 5_000 instead of 1_000.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant