Skip to content

perf: use anyio fast_acquire for Lock and Semaphore#970

Merged
Kludex merged 2 commits into
pydantic:mainfrom
mbeijen:perf/fast-acquire-locks
May 20, 2026
Merged

perf: use anyio fast_acquire for Lock and Semaphore#970
Kludex merged 2 commits into
pydantic:mainfrom
mbeijen:perf/fast-acquire-locks

Conversation

@mbeijen
Copy link
Copy Markdown
Contributor

@mbeijen mbeijen commented May 19, 2026

Reinstates encode/httpcore#953 which was reverted in encode/httpcore#1002 for process reasons, not technical ones. fast_acquire=True skips an unnecessary event loop yield on uncontended lock acquires, eliminating two round-trips per request through the connection pool.

Requires anyio >= 4.5.0 (bumped in pyproject.toml).

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 19, 2026

Merging this PR will not alter performance

✅ 7 untouched benchmarks


Comparing mbeijen:perf/fast-acquire-locks (ddc00d9) with main (79f788b)

Open in CodSpeed

@mbeijen mbeijen force-pushed the perf/fast-acquire-locks branch from 3cb0ea4 to 9008173 Compare May 19, 2026 19:19
Reinstates encode/httpcore#953 which was reverted in encode/httpcore#1002
for process reasons, not technical ones. fast_acquire=True skips an
unnecessary event loop yield on uncontended lock acquires, eliminating
two round-trips per request through the connection pool.

Requires anyio >= 4.5.0 (bumped in pyproject.toml).
@mbeijen mbeijen force-pushed the perf/fast-acquire-locks branch from 9008173 to 4922f24 Compare May 20, 2026 06:58
@Kludex Kludex merged commit b4c5940 into pydantic:main May 20, 2026
10 checks passed
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.

2 participants