Repository navigation
fix: Numerous small performance and correctness issues - #211
Conversation
|
|
||
| class ClientMultiplexer(Generic[_Key, _Client]): | ||
| _OpenedClientFactory = Callable[[], _Client] | ||
| _OpenedClientFactory = Callable[[_Key], _Client] |
There was a problem hiding this comment.
There was a lot of "self" time in get_or_create callers from constructing the factory to pass in. This is in the publish hot path, hence this change
| _closer: _ClientCloser | ||
| _lock: asyncio.Lock | ||
| _live_clients: Dict[_Key, _Client] | ||
| _live_clients: Dict[_Key, Awaitable[_Client]] |
There was a problem hiding this comment.
There was a lot of time in acquiring the lock in the publish hotpath- this change makes the lock not necessary
|
|
||
| _multiplexer: ClientMultiplexer[SubscriptionPath, StreamingPullFuture] | ||
| _lock: Lock | ||
| _live_clients: Set[StreamingPullFuture] |
There was a problem hiding this comment.
Previously, the subscriber enforced that there was only one open subscription stream per-subscription per-client, but there's actually no need for this.
|
|
||
| def should_flush(self) -> bool: | ||
| return self._tester.test(item.request for item in self._requests) | ||
| def size(self) -> BatchSize: |
There was a problem hiding this comment.
Most of the CPU in the publish path was in should_flush calls, which had to construct an iterable and iterate through every time.
| element_count=1, byte_count=PubSubMessage.pb(request).ByteSize() | ||
| ) | ||
|
|
||
| def _should_flush(self) -> bool: |
There was a problem hiding this comment.
if you'll note on the left... batching settings were previously ignored
🤖 I have created a release \*beep\* \*boop\* --- ### [1.1.1](https://www.github.com/googleapis/python-pubsublite/compare/v1.1.0...v1.1.1) (2021-09-07) ### Bug Fixes * Add workaround for grpc/grpc#25364 ([#213](https://www.github.com/googleapis/python-pubsublite/issues/213)) ([e417bf3](https://www.github.com/googleapis/python-pubsublite/commit/e417bf39fe32c995e5ac2e0a807a10fee3f37d9f)) * Numerous small performance and correctness issues ([#211](https://www.github.com/googleapis/python-pubsublite/issues/211)) ([358a1d8](https://www.github.com/googleapis/python-pubsublite/commit/358a1d8a429086ee75373260eb087a9dd171e3e6)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕