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

Reduce allocations in poll(2) implementation #1705

Closed

Conversation

Thomasdezeeuw
Copy link
Collaborator

This changes the poll(2) implementation to reuse to Vectors, so that we don't allocate in calls to Poll::poll in most cases. 1 The downside to this is that Poll and Registry will contains two Vecs, which will increase their size. Especially for Registry this is annoying because they are never used. It might be worth considering exposing the same Poll/Registry split in the sys module to avoid this overhead for Registry.

This also contains a small cleanup commit to make the code match the style of the other files.

Closes #1701

/cc @jasta this is what I meant in #1687 (comment) and #1687 (comment)

Footnotes

  1. Initially the vectors will be zero-sized and thus it will allocate in the first (couple of) calls, but at some point the capacity should be sufficient for further calls to no longer allocate.

@Thomasdezeeuw
Copy link
Collaborator Author

Not doing this for now.

@Thomasdezeeuw Thomasdezeeuw deleted the #1701_less_allocs_in_poll branch December 23, 2023 17:20
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.

poll: Optimize locks and allocations in the critical path
1 participant