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

Micro-optimize OutputFilenames #68409

Merged
merged 3 commits into from Jan 23, 2020
Merged

Micro-optimize OutputFilenames #68409

merged 3 commits into from Jan 23, 2020

Conversation

@sinkuu
Copy link
Contributor

sinkuu commented Jan 21, 2020

For example, its methods consume 6% of time during debug-compiling a warp example:
Screenshot (debug-compiling a warp example)

This PR optimize them a bit by using PathBuf::set_extension instead of Path::with_extension, to avoid cloning PathBuf excessively.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jan 21, 2020

r? @matthewjasper

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

Copy link
Member

Mark-Simulacrum left a comment

r=me with my comment resolved

let mut s = String::with_capacity(self.out_filestem.len() + self.extra.len());
s.push_str(&self.out_filestem);
s.push_str(&self.extra);
s

This comment has been minimized.

Copy link
@Mark-Simulacrum

Mark-Simulacrum Jan 21, 2020

Member

We can go a bit further here -- we don't modify the out_filestem and extra after construction, so a few more optimizations can apply here, see https://github.com/Mark-Simulacrum/rust/pull/new/output-filenames-opt -- if you steal the commits/changes from there, then that'll push this even closer to optimal :)

This comment has been minimized.

Copy link
@sinkuu

sinkuu Jan 21, 2020

Author Contributor

Thanks! I've added your commits to this PR.

We already have ownership of the base path, so no need to clone it (within
Path::with_extension).
@sinkuu sinkuu force-pushed the sinkuu:temp_path branch from 6804e2f to dc97181 Jan 21, 2020
@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jan 21, 2020

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 21, 2020

📌 Commit dc97181 has been approved by Mark-Simulacrum

tmandry added a commit to tmandry/rust that referenced this pull request Jan 22, 2020
Micro-optimize OutputFilenames

For example, its methods consume 6% of time during debug-compiling a `warp` example:
![Screenshot (debug-compiling a `warp` example)](https://user-images.githubusercontent.com/7091080/72780288-d74f1580-3c61-11ea-953b-34e59ca682f9.png)

This PR optimize them a bit by using `PathBuf::set_extension` instead of `Path::with_extension`, to avoid cloning `PathBuf` excessively.
bors added a commit that referenced this pull request Jan 22, 2020
Rollup of 8 pull requests

Successful merges:

 - #68133 (Slimmer syntax)
 - #68253 (add bare metal ARM Cortex-A targets to rustc)
 - #68361 (Unbreak linking with lld 9 on FreeBSD 13.0-CURRENT i386)
 - #68388 (Make `TooGeneric` error in WF checking a proper error)
 - #68409 (Micro-optimize OutputFilenames)
 - #68410 (Export weak symbols used by MemorySanitizer)
 - #68425 (Fix try-op diagnostic in E0277 for methods)
 - #68440 (bootstrap: update clippy subcmd decription)

Failed merges:

 - #68441 (pprust: use as_deref)

r? @ghost
tmandry added a commit to tmandry/rust that referenced this pull request Jan 22, 2020
Micro-optimize OutputFilenames

For example, its methods consume 6% of time during debug-compiling a `warp` example:
![Screenshot (debug-compiling a `warp` example)](https://user-images.githubusercontent.com/7091080/72780288-d74f1580-3c61-11ea-953b-34e59ca682f9.png)

This PR optimize them a bit by using `PathBuf::set_extension` instead of `Path::with_extension`, to avoid cloning `PathBuf` excessively.
bors added a commit that referenced this pull request Jan 22, 2020
Rollup of 8 pull requests

Successful merges:

 - #68253 (add bare metal ARM Cortex-A targets to rustc)
 - #68361 (Unbreak linking with lld 9 on FreeBSD 13.0-CURRENT i386)
 - #68388 (Make `TooGeneric` error in WF checking a proper error)
 - #68409 (Micro-optimize OutputFilenames)
 - #68410 (Export weak symbols used by MemorySanitizer)
 - #68425 (Fix try-op diagnostic in E0277 for methods)
 - #68440 (bootstrap: update clippy subcmd decription)
 - #68441 (pprust: use as_deref)

Failed merges:

r? @ghost
tmandry added a commit to tmandry/rust that referenced this pull request Jan 22, 2020
Micro-optimize OutputFilenames

For example, its methods consume 6% of time during debug-compiling a `warp` example:
![Screenshot (debug-compiling a `warp` example)](https://user-images.githubusercontent.com/7091080/72780288-d74f1580-3c61-11ea-953b-34e59ca682f9.png)

This PR optimize them a bit by using `PathBuf::set_extension` instead of `Path::with_extension`, to avoid cloning `PathBuf` excessively.
bors added a commit that referenced this pull request Jan 22, 2020
Rollup of 11 pull requests

Successful merges:

 - #67195 ([experiment] Add `-Z no-link` flag)
 - #68253 (add bare metal ARM Cortex-A targets to rustc)
 - #68361 (Unbreak linking with lld 9 on FreeBSD 13.0-CURRENT i386)
 - #68388 (Make `TooGeneric` error in WF checking a proper error)
 - #68391 (compiletest: Simplify multi-debugger support)
 - #68409 (Micro-optimize OutputFilenames)
 - #68410 (Export weak symbols used by MemorySanitizer)
 - #68425 (Fix try-op diagnostic in E0277 for methods)
 - #68440 (bootstrap: update clippy subcmd decription)
 - #68441 (pprust: use as_deref)
 - #68462 (librustc_mir: don't allocate vectors where slices will do.)

Failed merges:

r? @ghost
tmandry added a commit to tmandry/rust that referenced this pull request Jan 23, 2020
Micro-optimize OutputFilenames

For example, its methods consume 6% of time during debug-compiling a `warp` example:
![Screenshot (debug-compiling a `warp` example)](https://user-images.githubusercontent.com/7091080/72780288-d74f1580-3c61-11ea-953b-34e59ca682f9.png)

This PR optimize them a bit by using `PathBuf::set_extension` instead of `Path::with_extension`, to avoid cloning `PathBuf` excessively.
bors added a commit that referenced this pull request Jan 23, 2020
Rollup of 10 pull requests

Successful merges:

 - #67195 ([experiment] Add `-Z no-link` flag)
 - #68253 (add bare metal ARM Cortex-A targets to rustc)
 - #68361 (Unbreak linking with lld 9 on FreeBSD 13.0-CURRENT i386)
 - #68388 (Make `TooGeneric` error in WF checking a proper error)
 - #68409 (Micro-optimize OutputFilenames)
 - #68410 (Export weak symbols used by MemorySanitizer)
 - #68425 (Fix try-op diagnostic in E0277 for methods)
 - #68440 (bootstrap: update clippy subcmd decription)
 - #68441 (pprust: use as_deref)
 - #68462 (librustc_mir: don't allocate vectors where slices will do.)

Failed merges:

r? @ghost
@bors bors merged commit dc97181 into rust-lang:master Jan 23, 2020
4 checks passed
4 checks passed
pr Build #20200121.67 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-7) Linux x86_64-gnu-llvm-7 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
@sinkuu sinkuu deleted the sinkuu:temp_path branch Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.