-
Notifications
You must be signed in to change notification settings - Fork 2
Reduce the memory allocation for AE #347
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
base: unstable
Are you sure you want to change the base?
Conversation
please describe what it does. |
you're right, extra indirection caused significant regression. |
when the connected clients reach the |
ok, so now it's the same as the original version, and we just avoid the big allocation at startup, and instead gradually grow when needed. regarding the test, i suppose you should also test with 10k clients, and it'll show the same memory usage. |
@oranagra update the comment in #347 (comment), got the result as expected. |
still, despite being better than what we have now. i'm not sure it makes it ok to hold a many (10?) event loops. |
i can't think of a more efficient way to do it, there's no hotter path than it, any indirection overhead is magnified |
well, so maybe coupling that gradual memory increase, with a gradual increase of IO thread count would be an ok mitigation. |
Currently, the event loop allocates memory for events and fires at startup based on the maximum client limit (max client). This can lead to significant memory waste if the max client is set high but the actual number of active connections remains low.
This PR introduces a dynamic memory allocation approach.
events
andfired
are now allocated based on the actual number of active client numbers (maxfd).If maxfd exceeds the current allocated space, memory is expanded by doubling the current size.
This strategy minimizes frequent reallocations while preventing excessive memory usage when only a small number of clients are connected.