Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize connection use in stream_conversations #1080

Open
insipx opened this issue Sep 20, 2024 · 0 comments
Open

Optimize connection use in stream_conversations #1080

insipx opened this issue Sep 20, 2024 · 0 comments
Labels
enhancement New feature or request perf

Comments

@insipx
Copy link
Contributor

insipx commented Sep 20, 2024

stream_conversations with callback pulls a new connection from the database multiple times, despite theoretically having the ability to do one of
1.) hold on to one connection for the duration of the stream
2.) pull one connection for all its operations before adding it back to the pool

Here's where we pull connections:

  • transaction_async pulls a new connection for processing a new welcome
  • pulls another connection again after the transaction for other operations
  • DM groups will pull yet another connection when checking for DM groups.

instead, we can create a new transaction function wrapping the existing one transaction_async_with_provider to reuse a provider, and then reuse that connection for the subsequent operations. this should reduce some churn in the Pool upon getting a new welcome/group in the stream

Then require that process_streamed_welcome accept a provider

This will allow us to instantiate a provider at the head of the stream message and use it for all ops

@insipx insipx added enhancement New feature or request perf labels Sep 20, 2024
@insipx insipx changed the title Optimize connection use in stream_conversations_with_callback Optimize connection use in stream_conversations Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request perf
Projects
Status: No status
Development

No branches or pull requests

1 participant