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 CPU usage when creating short connections frequently #473

Open
djshow832 opened this issue Feb 7, 2024 · 0 comments
Open

Optimize CPU usage when creating short connections frequently #473

djshow832 opened this issue Feb 7, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@djshow832
Copy link
Collaborator

djshow832 commented Feb 7, 2024

Development Task

When the client creates and destroys 300 connections per second, the CPU usage of TiProxy is up to 30%.

The main overhead is dialing the backend and forwarding messages during handshake. We may need a connection multiplex to optimize it.

However, we can do some minor optimizations without touching the architecture:

  • Reuse memory in bufio.NewReaderSize(), bufio.NewWriterSize(), and readOnePacket.
  • Save on-stack memory to avoid allocating a new stack in handshakeFirstTime.

The overall frame graph:
overall

Allocate duplicate memory:
malloc

@djshow832 djshow832 added the enhancement New feature or request label Feb 7, 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
Projects
None yet
Development

No branches or pull requests

1 participant