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

Please eliminating the allocations introduced by v1.38.1 #6757

Closed
viciousstar opened this issue Aug 7, 2024 · 6 comments · Fixed by #6779
Closed

Please eliminating the allocations introduced by v1.38.1 #6757

viciousstar opened this issue Aug 7, 2024 · 6 comments · Fixed by #6779
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-time Module: tokio/time

Comments

@viciousstar
Copy link

Is your feature request related to a problem? Please describe.
Tokio version 1.38.1 introducing excessive memory allocations .
In version 1.38, our memory allocation QPS was at 1k/s, but after upgrading to 1.38.1, it became 3k/s. Currently, we are not sure if this has any impact on the overall performance of our application. our application is a proxy of redis, the complexity of memory allocation QPS may increase to n from 1.

Describe the solution you'd like
eliminating the allocations introduced from v1.38.1

Describe alternatives you've considered
No

Additional context

@viciousstar viciousstar added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Aug 7, 2024
@viciousstar viciousstar changed the title Please eliminating the allocations introduced from v1.38.1. Please eliminating the allocations introduced by v1.38.1 Aug 7, 2024
@Darksonn Darksonn added the M-time Module: tokio/time label Aug 7, 2024
@Darksonn
Copy link
Contributor

Darksonn commented Aug 7, 2024

One option could be to wrap the wheels in an RwLock. That way, we can lock the write lock and access the mutex contents with Mutex::get_mut. All other accesses could use a read lock to avoid blocking each other.

@viciousstar
Copy link
Author

If I do not want to use v1.38.1, which version should we use? v1.37?

@Darksonn
Copy link
Contributor

Darksonn commented Aug 8, 2024

You can use 1.37.0.

@viciousstar
Copy link
Author

In the scenario of a total request of 30,000 requests per second, the number of memory allocations per second has risen from 6k to 18k.

@tglane
Copy link
Contributor

tglane commented Aug 15, 2024

I'd like to work on this. Will open a PR soon.

@hawkw
Copy link
Member

hawkw commented Aug 15, 2024

The approach described by @Darksonn in #6757 (comment) seems like the right solution to me, at least for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-time Module: tokio/time
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants