Skip to content

Hot path optimizations#20

Merged
lesnik512 merged 2 commits intomainfrom
hot-path-optimizations
May 3, 2026
Merged

Hot path optimizations#20
lesnik512 merged 2 commits intomainfrom
hot-path-optimizations

Conversation

@lesnik512
Copy link
Copy Markdown
Member

No description provided.

lesnik512 and others added 2 commits May 3, 2026 17:49
…op dead branch

- Cache total_pending as a counter on _StreamingState instead of summing
  partition lengths every loop iteration (#5).
- Run per-consumer commits via asyncio.gather so multi-consumer setups
  overlap their network round-trips. Single-consumer (the common case) is
  unchanged in cost (#7).
- Remove the always-true `if self._limiter:` branch in handle_task; the
  ctor enforces concurrency_limit >= 1, and Semaphore is always truthy (#8).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace the per-commit asyncio.sleep Task with a float deadline on
_StreamingState. asyncio.wait already accepts a `timeout=` argument; passing
`max(deadline - loop.time(), 0.0)` removes one Task allocation per commit
plus the matching cancel-on-reset. The timer is no longer in the wait set,
so the per-iteration callback registration cost goes away too.

Behavior is unchanged: pending empty ⇒ deadline is None (no timer);
deadline is set on the first task absorbed into empty pending; reset to a
fresh interval after every commit while pending still has tasks; cleared
when pending drains.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@lesnik512 lesnik512 self-assigned this May 3, 2026
@lesnik512 lesnik512 merged commit 0485c16 into main May 3, 2026
5 checks passed
@lesnik512 lesnik512 deleted the hot-path-optimizations branch May 3, 2026 19:46
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