-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Make entrypoints more efficient part 2 #5621
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
udoprog
added
C-enhancement
Category: A PR with an enhancement or bugfix.
A-tokio-macros
Area: The tokio-macros crate
M-macros
Module: macros in the main Tokio crate
labels
Apr 13, 2023
taiki-e
reviewed
Apr 15, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This is more robust and much easy to maintain (and understand) than #4513.
taiki-e
approved these changes
Apr 15, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Darksonn
approved these changes
Apr 15, 2023
Darksonn
changed the title
Make entrypoints more efficient part 2 (closes #4513)
Make entrypoints more efficient part 2
Apr 15, 2023
This was referenced Apr 25, 2023
crapStone
pushed a commit
to Calciumdibromid/CaBr2
that referenced
this pull request
Apr 29, 2023
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [tokio](https://tokio.rs) ([source](https://github.com/tokio-rs/tokio)) | dependencies | minor | `1.27.0` -> `1.28.0` | | [tokio](https://tokio.rs) ([source](https://github.com/tokio-rs/tokio)) | dev-dependencies | minor | `1.27.0` -> `1.28.0` | --- ### Release Notes <details> <summary>tokio-rs/tokio</summary> ### [`v1.28.0`](https://github.com/tokio-rs/tokio/releases/tag/tokio-1.28.0): Tokio v1.28.0 [Compare Source](tokio-rs/tokio@tokio-1.27.0...tokio-1.28.0) ##### 1.28.0 (April 25th, 2023) ##### Added - io: add `AsyncFd::async_io` ([#​5542]) - io: impl BufMut for ReadBuf ([#​5590]) - net: add `recv_buf` for `UdpSocket` and `UnixDatagram` ([#​5583]) - sync: add `OwnedSemaphorePermit::semaphore` ([#​5618]) - sync: add `same_channel` to broadcast channel ([#​5607]) - sync: add `watch::Receiver::wait_for` ([#​5611]) - task: add `JoinSet::spawn_blocking` and `JoinSet::spawn_blocking_on` ([#​5612]) ##### Changed - deps: update windows-sys to 0.48 ([#​5591]) - io: make `read_to_end` not grow unnecessarily ([#​5610]) - macros: make entrypoints more efficient ([#​5621]) - sync: improve Debug impl for `RwLock` ([#​5647]) - sync: reduce contention in `Notify` ([#​5503]) ##### Fixed - net: support `get_peer_cred` on AIX ([#​5065]) - sync: avoid deadlocks in `broadcast` with custom wakers ([#​5578]) ##### Documented - sync: fix typo in `Semaphore::MAX_PERMITS` ([#​5645]) - sync: fix typo in `tokio::sync::watch::Sender` docs ([#​5587]) [#​5065]: tokio-rs/tokio#5065 [#​5503]: tokio-rs/tokio#5503 [#​5542]: tokio-rs/tokio#5542 [#​5578]: tokio-rs/tokio#5578 [#​5583]: tokio-rs/tokio#5583 [#​5587]: tokio-rs/tokio#5587 [#​5590]: tokio-rs/tokio#5590 [#​5591]: tokio-rs/tokio#5591 [#​5607]: tokio-rs/tokio#5607 [#​5610]: tokio-rs/tokio#5610 [#​5611]: tokio-rs/tokio#5611 [#​5612]: tokio-rs/tokio#5612 [#​5618]: tokio-rs/tokio#5618 [#​5621]: tokio-rs/tokio#5621 [#​5645]: tokio-rs/tokio#5645 [#​5647]: tokio-rs/tokio#5647 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS42My4xIiwidXBkYXRlZEluVmVyIjoiMzUuNjQuMCJ9--> Co-authored-by: cabr2-bot <cabr2.help@gmail.com> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1875 Reviewed-by: crapStone <crapstone@noreply.codeberg.org> Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org> Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-tokio-macros
Area: The tokio-macros crate
C-enhancement
Category: A PR with an enhancement or bugfix.
M-macros
Module: macros in the main Tokio crate
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a different stab at #4513.
We use syn to parse the signature into our own
ItemFn
, maintaining most of the existing API but avoiding parsing (and reparsing) all statements except the parts we are interested in.For signature parsing, we rely almost entirely on
syn
. The only notable trouble is the parsing of inner attributes, for which I believe I've matchedsyn
's behavior: The inner attributes are expanded as outer attributes instead. In theory we could expand them as inner attributes to the newly generated function but that doesn't seem to be necessary and I did it like this to match the previous expansion more precisely.As a basic test, I modified the tinyhttp example and put everything in the main function, these were the timing differences I got for the macro:
Before:
After:
Note: We're still not down to microseconds like the other parsing method, but now at least we don't have to worry about signatures and how to remove
syn
as a direct dependency without msrv stuff breaking 😄As before, this is most notable for me when I was working on large entrypoints in rust-analyzer, for which large kinds of input latency caused diagnostics to be noticeably delayed. I've since refactored all of my entrpoints to quickly call another function to avoid this, but this should still be valuable for the future.