Skip to content

Fix high cpu usage#19

Merged
Az107 merged 2 commits intoAz107:masterfrom
miky-rola:high-cpu-usage
Apr 9, 2025
Merged

Fix high cpu usage#19
Az107 merged 2 commits intoAz107:masterfrom
miky-rola:high-cpu-usage

Conversation

@miky-rola
Copy link
Contributor

@miky-rola miky-rola commented Apr 8, 2025

  • Connection Management: The logic ensures that idle or closed connections are cleaned up to free resources, while active connections are kept alive for better performance.

  • Non-blocking I/O: Handling [WouldBlock] errors allows the server to remain responsive and process multiple connections simultaneously.

  • Keep-Alive Support: Adding support for persistent connections improves efficiency by reducing the overhead of establishing new connections for every request.

  • Chunked Responses: Writing responses incrementally ensures that large responses do not block the server, enabling it to handle other requests concurrently.

Copy link
Owner

@Az107 Az107 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s bring back the priority list for now, and optimice it later to justify the complexity.
Apart of that , well job

};
let pool: Arc<(Mutex<VecDeque<TcpStream>>, Condvar)> =
Arc::new((Mutex::new(VecDeque::new()), Condvar::new()));
let priority_list: Arc<Mutex<Vec<usize>>> = Arc::new(Mutex::new(Vec::new()));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handles the load balancing of the threads.
It not provides a significant performance boost (~3%), but maybe we could improve the LB system

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@Az107 Az107 merged commit 387635f into Az107:master Apr 9, 2025
1 check 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