Skip to content

Optimize test suite duration by caching test infrastructure#4004

Open
st0012 wants to merge 7 commits intomainfrom
autoresearch/test-duration-2026-03-12
Open

Optimize test suite duration by caching test infrastructure#4004
st0012 wants to merge 7 commits intomainfrom
autoresearch/test-duration-2026-03-12

Conversation

@st0012
Copy link
Member

@st0012 st0012 commented Mar 12, 2026

Summary

  • Cache RuboCopFormatter at the class level in formatting and diagnostics expectation tests, avoiding repeated creation of RuboCopRunner instances (2 per test × 2,352 tests)
  • Cache GlobalState at the class level in ExpectationsTestRunner, avoiding redundant initialization per test
  • Skip addon loading in Definition and Hover expectation tests where addons aren't needed (with_server(load_addons: true) costs ~38ms vs ~2ms without)

In total, this reduces the CI duration by about 10min (~30 -> 20), which is a 33% reduction.

Test plan

  • All existing tests pass (18,329 tests, same count, same 2 pre-existing nix-path failures)
  • No new failures or errors introduced
  • Compare CI test duration against main branch baseline

st0012 added 6 commits March 12, 2026 20:03
Reduces test_duration from ~454s to ~301s (33% improvement)
Addon loading (especially RuboCop addon) costs ~103ms per test.
Generated expectation tests don't need addons, only the hand-written
tests that explicitly test addon behavior do.

Reduces test_duration from ~301s to ~217s (28% improvement).
Most hand-written tests in these classes don't need addons.
Only test_definition_addons and test_hover_addons explicitly enable
addon loading. Saves ~3s from avoiding ~79 addon activation cycles.
@st0012 st0012 added chore Chore task server This pull request should be included in the server gem's release notes labels Mar 13, 2026
@st0012 st0012 self-assigned this Mar 13, 2026
@st0012 st0012 marked this pull request as ready for review March 13, 2026 01:06
@st0012 st0012 requested a review from a team as a code owner March 13, 2026 01:06
@st0012 st0012 force-pushed the autoresearch/test-duration-2026-03-12 branch from d143dc6 to 1454173 Compare March 13, 2026 01:12
Copy link
Contributor

@alexcrocha alexcrocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Chore task server This pull request should be included in the server gem's release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants