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.
eventsandfiredare 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.