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

Cheaper doc comments #65750

Merged
merged 2 commits into from Nov 7, 2019

Conversation

@nnethercote
Copy link
Contributor

nnethercote commented Oct 24, 2019

This PR implements the idea from #60935: represent doc comments more cheaply, rather than converting them into #[doc="..."] attribute form. Unlike #60936 (which is about coalescing doc comments to reduce their number), this approach does not have any backwards compatibility concerns, and it eliminates about 80-90% of the current cost of doc comments (as estimated using the numbers in #60930, which eliminated the cost of doc comments entirely by treating them as normal comments).

r? @petrochenkov

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Oct 24, 2019

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Oct 24, 2019

Awaiting bors try build completion

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 24, 2019

⌛️ Trying commit 0b907f7 with merge b773ddd...

bors added a commit that referenced this pull request Oct 24, 2019
Cheaper doc comments

This PR implements the idea from #60935: represent doc comments specially, rather than converting them into `#[doc="..."]` attribute form. Unlike #60936, this approach does not have any backwards compatibility concerns, and it eliminates about 80-90% of the current cost of doc comments (as estimated using the numbers in #60930, which eliminated the cost of doc comments entirely by treating them as normal comments).

r? @petrochenkov
@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Oct 24, 2019

@Manishearth, @nrc: this PR will affect Clippy and rustfmt.

@nnethercote nnethercote force-pushed the nnethercote:cheaper-doc-comments branch from 0b907f7 to 42bac15 Oct 24, 2019
@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Oct 24, 2019

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Oct 24, 2019

Queued b773ddd with parent 4a8c5b2, future comparison URL.

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Oct 25, 2019

Finished benchmarking try commit b773ddd, comparison URL.

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Oct 25, 2019

Perf results are excellent, as expected.

@Centril

This comment has been minimized.

Copy link
Member

Centril commented Oct 25, 2019

r? @Centril @bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 25, 2019

📌 Commit 42bac15 has been approved by Centril

@Centril

This comment has been minimized.

Copy link
Member

Centril commented Oct 25, 2019

@bors rollup=never (perf)

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Oct 25, 2019

@bors r-
I really wanted to review this, can it wait for a day or so?

@petrochenkov petrochenkov self-assigned this Oct 25, 2019
@Centril

This comment has been minimized.

Copy link
Member

Centril commented Oct 25, 2019

Sure -- I don't mind.
(I did double check the diff and it all seems good.)

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Oct 25, 2019

cc @topecongiro for possible rustfmt breakage

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 25, 2019

☔️ The latest upstream changes (presumably #65804) made this pull request unmergeable. Please resolve the merge conflicts.

@nnethercote nnethercote force-pushed the nnethercote:cheaper-doc-comments branch from 42bac15 to 7afba1a Oct 25, 2019
@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Oct 25, 2019

I have rebased.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 6, 2019

⌛️ Testing commit 9964212 with merge bc32c9c...

bors added a commit that referenced this pull request Nov 6, 2019
Cheaper doc comments

This PR implements the idea from #60935: represent doc comments more cheaply, rather than converting them into `#[doc="..."]` attribute form. Unlike #60936 (which is about coalescing doc comments to reduce their number), this approach does not have any backwards compatibility concerns, and it eliminates about 80-90% of the current cost of doc comments (as estimated using the numbers in #60930, which eliminated the cost of doc comments entirely by treating them as normal comments).

r? @petrochenkov
@Centril

This comment has been minimized.

Copy link
Member

Centril commented Nov 6, 2019

Yielding to r0llup. Also, toolstate window is still in effect.

@bors retry

@Centril

This comment has been minimized.

Copy link
Member

Centril commented Nov 6, 2019

In the interim, let's @bors p=-1

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 6, 2019

☔️ The latest upstream changes (presumably #66143) made this pull request unmergeable. Please resolve the merge conflicts.

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Nov 6, 2019

@bors p=0

nnethercote added 2 commits Oct 23, 2019
This kind of thing just makes the code harder to read.
`AttrKind` is a new type with two variants, `Normal` and `DocComment`. It's a
big performance win (over 10% in some cases) because `DocComment` lets doc
comments (which are common) be represented very cheaply.

`Attribute` gets some new helper methods to ease the transition:
- `has_name()`: check if the attribute name matches a single `Symbol`; for
  `DocComment` variants it succeeds if the symbol is `sym::doc`.
- `is_doc_comment()`: check if it has a `DocComment` kind.
- `{get,unwrap}_normal_item()`: extract the item from a `Normal` variant;
  panic otherwise.

Fixes #60935.
@nnethercote nnethercote force-pushed the nnethercote:cheaper-doc-comments branch from 9964212 to eea6f23 Nov 6, 2019
@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Nov 6, 2019

@bors r=petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 6, 2019

📌 Commit eea6f23 has been approved by petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 7, 2019

⌛️ Testing commit eea6f23 with merge caf0187...

bors added a commit that referenced this pull request Nov 7, 2019
Cheaper doc comments

This PR implements the idea from #60935: represent doc comments more cheaply, rather than converting them into `#[doc="..."]` attribute form. Unlike #60936 (which is about coalescing doc comments to reduce their number), this approach does not have any backwards compatibility concerns, and it eliminates about 80-90% of the current cost of doc comments (as estimated using the numbers in #60930, which eliminated the cost of doc comments entirely by treating them as normal comments).

r? @petrochenkov
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 7, 2019

☀️ Test successful - checks-azure
Approved by: petrochenkov
Pushing caf0187 to master...

@bors bors added the merged-by-bors label Nov 7, 2019
@bors bors merged commit eea6f23 into rust-lang:master Nov 7, 2019
5 checks passed
5 checks passed
homu Test successful
Details
pr Build #20191106.32 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
msizanoen1 added a commit to msizanoen1/rust-clippy that referenced this pull request Nov 7, 2019
@nnethercote nnethercote deleted the nnethercote:cheaper-doc-comments branch Nov 13, 2019
bors added a commit that referenced this pull request Dec 1, 2019
syntax: Unify macro and attribute arguments in AST

The unified form (`ast::MacArgs`) represents parsed arguments instead of an unstructured token stream that was previously used for attributes.
It also tracks some spans and delimiter kinds better for fn-like macros and macro definitions.

I've been talking about implementing this with @nnethercote in #65750 (comment).
The parsed representation is closer to `MetaItem` and requires less token juggling during conversions, so it potentially may be faster.

r? @Centril
Centril added a commit to Centril/rust that referenced this pull request Dec 3, 2019
syntax: Unify macro and attribute arguments in AST

The unified form (`ast::MacArgs`) represents parsed arguments instead of an unstructured token stream that was previously used for attributes.
It also tracks some spans and delimiter kinds better for fn-like macros and macro definitions.

I've been talking about implementing this with @nnethercote in rust-lang#65750 (comment).
The parsed representation is closer to `MetaItem` and requires less token juggling during conversions, so it potentially may be faster.

r? @Centril
Centril added a commit to Centril/rust that referenced this pull request Dec 3, 2019
syntax: Unify macro and attribute arguments in AST

The unified form (`ast::MacArgs`) represents parsed arguments instead of an unstructured token stream that was previously used for attributes.
It also tracks some spans and delimiter kinds better for fn-like macros and macro definitions.

I've been talking about implementing this with @nnethercote in rust-lang#65750 (comment).
The parsed representation is closer to `MetaItem` and requires less token juggling during conversions, so it potentially may be faster.

r? @Centril
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.