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

perf(gateway): remove one Shard::next_message allocation #1900

Closed
wants to merge 1 commit into from

Conversation

vilgotf
Copy link
Member

@vilgotf vilgotf commented Sep 11, 2022

Twilight uses Box::pin when pinning is required, but allocating a Box is in most cases not needed. pin-project-lite avoids this allocation and internally guarentees that the safety contract of Pin::new_unchecked is upheld.

Although the entire NextMessageFuture can be replaced with tokio::select! (with biased), this is not done due to its archaic syntax.

pin-project-lite is commonly used in the async ecosystem and Twilight already transiently depends upon it via, for example, tokio and hyper.

Doc comments cannot be put on struct items due to taiki-e/pin-project-lite#3, the recommended workaround is to use normal comments instead.

@github-actions github-actions bot added c-gateway Affects the gateway crate t-perf Improves performace labels Sep 11, 2022
@vilgotf vilgotf force-pushed the vilgotf/perf/gateway/next-message-alloc branch from 4231c31 to aed068b Compare September 11, 2022 07:47
@7596ff
Copy link
Contributor

7596ff commented Oct 15, 2022

This contains elements of #1947, which I would like to resolve before commenting further.

@vilgotf vilgotf force-pushed the vilgotf/perf/gateway/next-message-alloc branch from 7366a6e to fdedcbc Compare October 16, 2022 05:20
@vilgotf vilgotf changed the base branch from next to vilgotf/feat/gateway/heartbeat-jitter October 16, 2022 05:20
Base automatically changed from vilgotf/feat/gateway/heartbeat-jitter to next October 16, 2022 06:33
@vilgotf vilgotf force-pushed the vilgotf/perf/gateway/next-message-alloc branch from fdedcbc to 23cb50c Compare October 16, 2022 07:54
@vilgotf vilgotf closed this Oct 16, 2022
@vilgotf vilgotf deleted the vilgotf/perf/gateway/next-message-alloc branch October 16, 2022 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-gateway Affects the gateway crate t-perf Improves performace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants