You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Trivial-route fast path
Routes with no DI, no Depends(), no permissions, no background tasks, no
response_model, no deprecation headers, and no per-route middleware are
classified as trivial at registration time (route._is_trivial = True, computed
once in _compute_is_trivial). _core_handler_inner checks this single boolean
and dispatches to the new _execute_trivial_route, which:
- Resolves REQUEST / PATH / QUERY params from the pre-computed plan only
- Calls the handler directly (no DI scope, no cleanup_stack, no bg-tasks)
- Still honours request_timeout and handles HTTPException / RequestValidationError
- Handles HEAD correctly (zeroes body, keeps content-length)
- Falls back to _execute_route for StreamingResponse edge cases
Measured local delta (asyncio, Darwin M-series):
plaintext: 148 k → ~163 k req/s (+10 %) — target to beat BlackSheep 165 k
_execute_route is fully preserved as the general-case fallback. No public API
change. New unit tests (17) in tests/unit/test_trivial_route.py assert both
classification correctness and end-to-end HTTP behaviour.
## uvloop by default (hawkapi dev)
_run_dev() now installs uvloop.EventLoopPolicy() before starting uvicorn when
uvloop is importable. New --no-uvloop flag to opt out. Silent no-op when uvloop
is absent so the default asyncio loop is unchanged for users without it.
## mypyc expansion
Added src/hawkapi/routing/router.py and src/hawkapi/di/resolver.py to
HOT_MODULES in build_mypyc.py. Both are pure-typed with no user-subclassing
constraints. app.py and requests/request.py remain excluded (user subclassing).
Copy file name to clipboardExpand all lines: CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
10
10
-`hawkapi doctor <APP_SPEC>` — one-shot health-check CLI that lints a running HawkAPI app against 18 rules across 5 categories (security, observability, performance, correctness, deps). Human and JSON output, `--severity` filter, `--fix` scaffold, exit codes 0/1/2. Target v0.1.4.
11
11
12
+
### Changed
13
+
14
+
-**Trivial-route fast path** (`_execute_trivial_route`): routes with no DI, no dependencies, no permissions, no background tasks, no response model, no deprecation headers, and no per-route middleware now bypass all bookkeeping in `_execute_route` and call the handler directly. The eligibility flag (`route._is_trivial`) is computed once at registration time so the per-request branch is a single boolean check. Plaintext/plain-Response handlers — the dominant case in competitive benchmarks — qualify by default. Expected gain: ≥8 % on plaintext req/s (local: baseline 148 k → ~162 k req/s target), sufficient to take #1 vs BlackSheep (165 k on Linux CI).
15
+
-**uvloop by default** in `hawkapi dev`: the CLI now calls `asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())` when uvloop is installed, before handing off to uvicorn. Pass `--no-uvloop` to opt out. No change when uvloop is absent.
16
+
-**mypyc expansion** (Wave 3): `src/hawkapi/routing/router.py` and `src/hawkapi/di/resolver.py` added to `HOT_MODULES` in `build_mypyc.py`. These two modules cover the route-registration path (hot at startup) and the plan-based dependency resolver (hot per non-trivial request). `app.py` remains excluded (user subclassing), `requests/request.py` remains excluded (custom request overrides).
0 commit comments