Skip to content

Implementation Plan: Perf — Drop-in Regex Package + Enable uvloop for MCP Server#2206

Merged
Trecek merged 8 commits into
developfrom
perf-drop-in-regex-package-enable-uvloop-for-mcp-server/2190
May 8, 2026
Merged

Implementation Plan: Perf — Drop-in Regex Package + Enable uvloop for MCP Server#2206
Trecek merged 8 commits into
developfrom
perf-drop-in-regex-package-enable-uvloop-for-mcp-server/2190

Conversation

@Trecek
Copy link
Copy Markdown
Collaborator

@Trecek Trecek commented May 8, 2026

Summary

Two independent, mechanical performance improvements with zero API changes:

  1. regex package: Add regex>=2026.1 to runtime deps and replace every import re with import regex as re across all src/autoskillit/ production modules except hooks/ and hook_registry.py (which are stdlib-only for subprocess safety). The regex package is a 100% API-compatible C-extension superset of re.

  2. uvloop for MCP server: Add uvloop>=0.21.0; sys_platform != "win32" to runtime deps and change the single anyio.run() call in cli/app.py:128 to pass backend="asyncio" and backend_options={"use_uvloop": True}. This applies exclusively to the MCP server entrypoint — the non-server asyncio.run() calls at cli/app.py:292,388 (used for quota_status and workspace_clean) are NOT changed, since those paths spawn subprocesses where uvloop is benchmarked 2x slower.

Acceptance Criteria

  • regex added to dependencies
  • uvloop enabled for MCP server backend
  • All existing tests pass
  • No subprocess spawning paths use uvloop

Architecture Impact

This PR includes validated architecture diagrams from the concurrency and module-dependency lenses. Please review the plan file for full diagram details.

Closes #2190

Implementation Plan

Plan file: /home/talon/projects/autoskillit-runs/impl-20260507-160445-342766/.autoskillit/temp/make-plan/perf_drop_in_regex_uvloop_plan_2026-05-07_160445.md

🤖 Generated with Claude Code via AutoSkillit

Token Usage Summary

Step Model count uncached output cache_read peak_ctx turns cache_write time
plan claude-sonnet-4-6 1 117 15.2k 489.6k 57.7k 61 51.6k 8m 22s
verify claude-sonnet-4-6 1 164 14.6k 946.2k 62.7k 62 50.1k 4m 20s
implement* MiniMax-M2.7-highspeed 1 1.9M 16.6k 1.9M 71.5k 133 79.8k 13m 33s
prepare_pr* MiniMax-M2.7-highspeed 1 81.7k 6.3k 172.4k 28.7k 17 41.1k 1m 40s
compose_pr* MiniMax-M2.7-highspeed 1 49.6k 1.2k 198.3k 28.7k 14 15.1k 37s
review_pr claude-sonnet-4-6 3 450 84.3k 3.2M 128.5k 222 300.4k 23m 0s
resolve_review claude-sonnet-4-6 2 570 36.4k 4.2M 88.4k 172 145.2k 23m 13s
ci_conflict_fix claude-sonnet-4-6 1 324 18.6k 2.1M 68.0k 93 55.4k 5m 50s
Total 2.0M 193.2k 13.2M 128.5k 738.6k 1h 20m

* Step used a non-Anthropic provider; caching behavior may differ.

Token Efficiency

Step LoC Changed cache_read/LoC cache_write/LoC output/LoC
plan 0
verify 0
implement 418 4478.4 190.8 39.8
prepare_pr 0
compose_pr 0
review_pr 0
resolve_review 74 57313.9 1962.3 491.5
ci_conflict_fix 1035 2014.1 53.5 17.9
Total 1527 8635.8 483.7 126.5

Model Usage Breakdown

Model steps uncached output cache_read cache_write time
claude-sonnet-4-6 3 473 41.1k 2.6M 156.6k 27m 27s
MiniMax-M2.7-highspeed 3 2.0M 24.1k 2.2M 135.9k 15m 50s

Trecek and others added 8 commits May 7, 2026 18:12
- Add regex>=2026.1 and uvloop>=0.21.0; sys_platform != 'win32' to runtime deps
- Replace bare `import re` with `import regex as re` across all src/autoskillit/
  production modules except hooks/ and hook_registry.py (stdlib-only boundary)
- Change cli/app.py:128 anyio.run() call to pass backend="asyncio" and
  backend_options={"use_uvloop": True} — enables uvloop for MCP server only
- Add test_src_uses_regex_not_bare_re arch guard (tests/arch/test_regex_import.py)
- Add test_serve_passes_uvloop_backend_options unit test
- Update test_rules_ci.py Pattern isinstance checks to accept regex.Pattern
  alongside re.Pattern (regex is a drop-in superset)
- Update tests/arch/CLAUDE.md file table with new test file

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
… change

Replacing `import re` (stdlib) with `import regex as re` (third-party) caused
ruff to insert a blank import-group separator line in several files, shifting
subsequent line numbers by +1. Update SESSION_SIZE_BUDGETS and
_LEGACY_JSON_WRITES to reflect the new line numbers.
core/ is IL-0 (stdlib-only, zero third-party imports). _install_detect.py,
github_url.py, and core/types/_type_helpers.py all use only basic regex
patterns that stdlib re handles identically.
…tError

uvloop has a sys_platform != 'win32' dependency marker, so anyio's asyncio
backend would raise ImportError when use_uvloop=True on Windows.
- test_regex_import: exempt core/ (IL-0, stdlib-only) from the regex
  guard; also check ast.ImportFrom to catch 'from re import ...' patterns
- test_rules_ci: assert regex.Pattern exclusively for _NO_RUNS_RE and
  _TIMED_OUT_RE — dual isinstance check was too weak and would pass if
  the regex migration were accidentally reverted
Production serve() evaluates sys.platform != 'win32' at call time, so the
test's unconditional assertion on use_uvloop is True would fail on Windows.
Monkeypatching sys.platform to 'linux' pins the evaluation to True, and
the docstring is updated to reflect the platform-conditional behavior.
…e uniformity

The _re alias was preserved from the original stdlib import re as _re migration
but the underscore prefix is unnecessary since _re is not re-exported. Aligns
with the codebase-wide convention of import regex as re.
…t-rebase pre-commit)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Trecek Trecek force-pushed the perf-drop-in-regex-package-enable-uvloop-for-mcp-server/2190 branch from 25f9ab6 to bcfe417 Compare May 8, 2026 01:18
@Trecek Trecek added this pull request to the merge queue May 8, 2026
Merged via the queue into develop with commit 0df8bf9 May 8, 2026
2 checks passed
@Trecek Trecek deleted the perf-drop-in-regex-package-enable-uvloop-for-mcp-server/2190 branch May 8, 2026 01:31
Trecek added a commit that referenced this pull request May 8, 2026
… MCP Server (#2206)

## Summary

Two independent, mechanical performance improvements with zero API
changes:

1. **regex package**: Add `regex>=2026.1` to runtime deps and replace
every `import re` with `import regex as re` across all
`src/autoskillit/` production modules **except** `hooks/` and
`hook_registry.py` (which are stdlib-only for subprocess safety). The
`regex` package is a 100% API-compatible C-extension superset of `re`.

2. **uvloop for MCP server**: Add `uvloop>=0.21.0; sys_platform !=
"win32"` to runtime deps and change the single `anyio.run()` call in
`cli/app.py:128` to pass `backend="asyncio"` and
`backend_options={"use_uvloop": True}`. This applies exclusively to the
MCP server entrypoint — the non-server `asyncio.run()` calls at
`cli/app.py:292,388` (used for `quota_status` and `workspace_clean`) are
NOT changed, since those paths spawn subprocesses where uvloop is
benchmarked 2x slower.

## Acceptance Criteria

- [ ] `regex` added to dependencies
- [ ] uvloop enabled for MCP server backend
- [ ] All existing tests pass
- [ ] No subprocess spawning paths use uvloop

## Architecture Impact

This PR includes validated architecture diagrams from the `concurrency`
and `module-dependency` lenses. Please review the plan file for full
diagram details.

Closes #2190

## Implementation Plan

Plan file:
`/home/talon/projects/autoskillit-runs/impl-20260507-160445-342766/.autoskillit/temp/make-plan/perf_drop_in_regex_uvloop_plan_2026-05-07_160445.md`

🤖 Generated with [Claude Code](https://claude.com/claude-code) via
AutoSkillit
<!-- autoskillit:pipeline-signature
steps=prepare_pr,run_arch_lenses,compose_pr,annotate_pr_diff,review_pr
-->

## Token Usage Summary

| Step | Model | count | uncached | output | cache_read | peak_ctx |
turns | cache_write | time |

|------|-------|-------|----------|--------|------------|----------|-------|-------------|------|
| plan | claude-sonnet-4-6 | 1 | 117 | 15.2k | 489.6k | 57.7k | 61 |
51.6k | 8m 22s |
| verify | claude-sonnet-4-6 | 1 | 164 | 14.6k | 946.2k | 62.7k | 62 |
50.1k | 4m 20s |
| implement* | MiniMax-M2.7-highspeed | 1 | 1.9M | 16.6k | 1.9M | 71.5k
| 133 | 79.8k | 13m 33s |
| fix | claude-sonnet-4-6 | 1 | 192 | 11.3k | 1.1M | 65.0k | 58 | 54.8k
| 14m 43s |
| prepare_pr* | MiniMax-M2.7-highspeed | 1 | 81.7k | 6.3k | 172.4k |
28.7k | 17 | 41.1k | 1m 40s |
| compose_pr* | MiniMax-M2.7-highspeed | 1 | 49.6k | 1.2k | 198.3k |
28.7k | 14 | 15.1k | 37s |
| **Total** | | | 2.0M | 65.2k | 4.8M | 71.5k | | 292.5k | 43m 18s |

\* *Step used a non-Anthropic provider; caching behavior may differ.*

## Token Efficiency

| Step | LoC Changed | cache_read/LoC | cache_write/LoC | output/LoC |
|------|-------------|----------------|-----------------|------------|
| plan | 0 | — | — | — |
| verify | 0 | — | — | — |
| implement | 418 | 4478.4 | 190.8 | 39.8 |
| fix | 18 | 62136.1 | 3046.1 | 627.6 |
| prepare_pr | 0 | — | — | — |
| compose_pr | 0 | — | — | — |
| **Total** | **436** | 11002.2 | 670.8 | 149.6 |

## Model Usage Breakdown

| Model | steps | uncached | output | cache_read | cache_write | time |
|-------|-------|----------|--------|------------|-------------|------|
| claude-sonnet-4-6 | 3 | 473 | 41.1k | 2.6M | 156.6k | 27m 27s |
| MiniMax-M2.7-highspeed | 3 | 2.0M | 24.1k | 2.2M | 135.9k | 15m 50s |

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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