-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Break up __pin_project_internal
#71
Break up __pin_project_internal
#71
Conversation
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! It's interesting that this improves performance. (IIRC, in proc-macro, it tended to take longer to compile the more macros there were. I thought the declarative macro had similar nature.)
As for CI failure, I think it can probably be fixed by rebasing.
__pin project internal
__pin_project_internal
This isn't useful by itself, but it sets things up for the next commit, which will break `__pin_project_internal!` into a number of smaller macros.
By removal internal rules, this commit turns one giant macro with 47 rules into 23 macros with a small number of rules each. I find the resulting code *much* easier to read; I found the original giant macro quite overwhelming. The new code also needs fewer comments because the code is clearer. The commit also fixes some minor formatting inconsistencies, such as always putting a space between the `!` and the `{` in a macro invocation, and using parens instead of braces for a few matchers.
It improves performance because it avoids lots of rule matching attempts that cannot succeed. |
I just upgraded to the latest Nightly and ran That command also changed lots of
but there are also some like this, which I don't understand:
|
dc21c09
to
8b97d80
Compare
Locally, ui test output is blessed by default.
The new diagnosis seems correct. I guess the rule reordering or rule separation may have changed the tokens that are considered expected to be matched first. |
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.
bors r+
Build succeeded: |
Thanks! |
Published in 0.2.9. |
I have been investigating expensive declarative macros recently.
pin_project_lite::pin_project
showed up as expensive for thefutures-lite
crate. This macro is very large, with 47 rules, many of these being internal rules. I thought that splitting it up into lots of smaller macros might help with performance. It only made a small (2%) performance improvement, but I think it increases readability enough that it's worth doing anyway. So I made this pull request.