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

Optimize indentation in the pretty printer. #59507

Merged
merged 1 commit into from Apr 1, 2019

Conversation

Projects
None yet
8 participants
@nnethercote
Copy link
Contributor

nnethercote commented Mar 28, 2019

Currently the pretty-printer calls write! for every space of
indentation. On some workloads the indentation level can exceed 100, and
a faster implementation reduces instruction counts by up to 7% on a few
workloads.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Mar 28, 2019

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Mar 28, 2019

Some local measurements. webrender_api is not part of rustc-perf, but I added it locally because of rust-lang-nursery/rustc-perf#312.

crates.io-check
        avg: -4.1%      min: -7.4%      max: -1.8%
webrender_api-check
        avg: -4.2%      min: -6.8%      max: -3.1%
cargo-check
        avg: -1.5%      min: -2.6%      max: -0.6%

The bigger improvements are for incremental compilation.

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Mar 28, 2019

@bors try

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 28, 2019

⌛️ Trying commit bca0279 with merge cf0a738...

bors added a commit that referenced this pull request Mar 28, 2019

Auto merge of #59507 - nnethercote:indent-with-SPACES, r=<try>
Optimize indentation in the pretty printer.

Currently the pretty-printer calls `write!` for every space of
indentation. On some workloads the indentation level can exceed 100, and
a faster implementation reduces instruction counts by up to 7% on a few
workloads.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 29, 2019

☀️ Try build successful - checks-travis
Build commit: cf0a738

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Mar 29, 2019

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Mar 29, 2019

Success: Queued cf0a738 with parent 237bf32, comparison URL.

@rust-timer

This comment has been minimized.

Copy link

rust-timer commented Mar 29, 2019

Finished benchmarking try commit cf0a738

Show resolved Hide resolved src/libsyntax/print/pp.rs Outdated
Show resolved Hide resolved src/libsyntax/print/pp.rs Outdated
@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Mar 29, 2019

r=me with nits addressed

Show resolved Hide resolved src/libsyntax/print/pp.rs Outdated

@nnethercote nnethercote force-pushed the nnethercote:indent-with-SPACES branch from bca0279 to a7292a7 Mar 29, 2019

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Mar 29, 2019

I addressed the nits. Measurements show that avoiding write! made a tiny improvement, saving another 0.1% on the best cases.

@bors r=petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 29, 2019

📌 Commit a7292a7 has been approved by petrochenkov

@ollie27
Copy link
Contributor

ollie27 left a comment

write isn't guaranteed to write all of the bytes.

@bors r-

Show resolved Hide resolved src/libsyntax/print/pp.rs Outdated
Show resolved Hide resolved src/libsyntax/print/pp.rs Outdated
@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Mar 29, 2019

^--- @bors r-

Optimize indentation in the pretty printer.
Currently the pretty-printer calls `write!` for every space of
indentation. On some workloads the indentation level can exceed 100, and
a faster implementation reduces instruction counts by up to 7% on a few
workloads.

@nnethercote nnethercote force-pushed the nnethercote:indent-with-SPACES branch from a7292a7 to 606f315 Mar 31, 2019

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

nnethercote commented Mar 31, 2019

I changed the write calls to write_all.

@bors r=petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 31, 2019

📌 Commit 606f315 has been approved by petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Mar 31, 2019

⌛️ Testing commit 606f315 with merge eab3eb3...

bors added a commit that referenced this pull request Mar 31, 2019

Auto merge of #59507 - nnethercote:indent-with-SPACES, r=petrochenkov
Optimize indentation in the pretty printer.

Currently the pretty-printer calls `write!` for every space of
indentation. On some workloads the indentation level can exceed 100, and
a faster implementation reduces instruction counts by up to 7% on a few
workloads.
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Apr 1, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: petrochenkov
Pushing eab3eb3 to master...

@bors bors added the merged-by-bors label Apr 1, 2019

@bors bors merged commit 606f315 into rust-lang:master Apr 1, 2019

1 check passed

homu Test successful
Details

@nnethercote nnethercote deleted the nnethercote:indent-with-SPACES branch Apr 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.