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

Cleanup codegen_llvm/back #54864

Merged
merged 10 commits into from
Nov 11, 2018
Merged

Conversation

ljedrz
Copy link
Contributor

@ljedrz ljedrz commented Oct 6, 2018

  • improve allocations
  • use Cow<'static, str> where applicable
  • use to_owned instead of to_string with string literals
  • remove a redundant continue
  • possible minor speedup in logic
  • use mem::replace instead of swap where more concise
  • remove 'static from consts
  • improve common patterns
  • remove explicit returns
  • whitespace & formatting fixes

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 6, 2018
Copy link
Member

@pnkfelix pnkfelix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commit the result of running rustfmt ? Just curious...

@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 9, 2018

@pnkfelix: you mean the whitespace one? No; those lines were hand-picked after having done all the other changes. I adjusted those spots along the way.

@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 16, 2018

It seems @pnkfelix is busy with NLL; r? @Mark-Simulacrum

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with landing this but some of these seem like they might not actually be improvements

src/librustc_codegen_llvm/back/bytecode.rs Outdated Show resolved Hide resolved
src/librustc_codegen_llvm/back/link.rs Outdated Show resolved Hide resolved
src/librustc_codegen_llvm/back/link.rs Outdated Show resolved Hide resolved
src/librustc_codegen_llvm/back/link.rs Show resolved Hide resolved
src/librustc_codegen_llvm/back/linker.rs Outdated Show resolved Hide resolved
src/librustc_codegen_llvm/back/linker.rs Outdated Show resolved Hide resolved
src/librustc_codegen_llvm/back/lto.rs Outdated Show resolved Hide resolved
@ljedrz ljedrz force-pushed the cleanup_codegen_llvm_back branch from a544455 to 60e123d Compare October 16, 2018 17:58
@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 16, 2018

@Mark-Simulacrum thanks for the thorough review! I think I addressed all the issues.

@ljedrz ljedrz force-pushed the cleanup_codegen_llvm_back branch from 60e123d to ec65cff Compare October 16, 2018 20:19
@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 19, 2018

@Mark-Simulacrum r? I won't be able to rebase for the next few days.

@ljedrz ljedrz closed this Oct 19, 2018
@ljedrz ljedrz deleted the cleanup_codegen_llvm_back branch October 19, 2018 12:36
@ljedrz ljedrz restored the cleanup_codegen_llvm_back branch October 19, 2018 13:27
@ljedrz ljedrz reopened this Oct 19, 2018
@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 19, 2018

The deletion was an accident. Travis should still be happy.

@ljedrz ljedrz force-pushed the cleanup_codegen_llvm_back branch from ec65cff to d2f2446 Compare October 29, 2018 09:20
@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 29, 2018

Included the suggestion by @sinkuu.

@bors
Copy link
Contributor

bors commented Nov 4, 2018

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

@ljedrz ljedrz force-pushed the cleanup_codegen_llvm_back branch from d2f2446 to b74c9d6 Compare November 5, 2018 12:57
@ljedrz
Copy link
Contributor Author

ljedrz commented Nov 5, 2018

Rebased.

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Nov 5, 2018

📌 Commit b74c9d60bf23b7d975dc87f5efeadd5fe937f605 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 5, 2018
@bors
Copy link
Contributor

bors commented Nov 5, 2018

⌛ Testing commit b74c9d60bf23b7d975dc87f5efeadd5fe937f605 with merge f0097bd6148de603f9f56d906f5a286d568be711...

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 10, 2018
@ljedrz ljedrz force-pushed the cleanup_codegen_llvm_back branch from 50c7e80 to 2f99d09 Compare November 10, 2018 18:25
@ljedrz
Copy link
Contributor Author

ljedrz commented Nov 10, 2018

I removed the memory-related commit; maybe I will come up with a solution in the future, but there's no point in holding back the rest of the changes.

@nagisa
Copy link
Member

nagisa commented Nov 10, 2018

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Nov 10, 2018

📌 Commit 2f99d09 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 10, 2018
@bors
Copy link
Contributor

bors commented Nov 10, 2018

⌛ Testing commit 2f99d09 with merge 6408162...

bors added a commit that referenced this pull request Nov 10, 2018
…acrum

Cleanup codegen_llvm/back

- improve allocations
- use `Cow<'static, str>` where applicable
- use `to_owned` instead of `to_string` with string literals
- remove a redundant `continue`
- possible minor speedup in logic
- use `mem::replace` instead of `swap` where more concise
- remove `'static` from consts
- improve common patterns
- remove explicit `return`s
- whitespace & formatting fixes
@bors
Copy link
Contributor

bors commented Nov 11, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: Mark-Simulacrum
Pushing 6408162 to master...

@bors bors merged commit 2f99d09 into rust-lang:master Nov 11, 2018
@ljedrz ljedrz deleted the cleanup_codegen_llvm_back branch November 11, 2018 07:05
bors added a commit that referenced this pull request Nov 11, 2018
codegen_llvm_back: improve allocations

This commit was split out from #54864. Last time it was causing an LLVM OOM, presumably due to aggressive preallocation strategy in `thin_lto`.

This time preallocations are more cautious and there are a few additional memory-related improvements (last 3 points from the list below).

- _gently_ preallocate vectors of known length
- `extend` instead of `append` where the argument is consumable
- turn 2 `push` loops into `extend`s
- create a vector from a function producing one instead of using `extend_from_slice` on it
- consume `modules` when no longer needed
- return an `impl Iterator` from `generate_lto_work`
- don't `collect` `globals`, as they are iterated over and consumed right afterwards

While I'm hoping it won't cause an OOM anymore, I would still consider this a "high-risk" PR and not roll it up.
bors added a commit that referenced this pull request Dec 4, 2018
codegen_llvm_back: improve allocations

This commit was split out from #54864. Last time it was causing an LLVM OOM, which was most probably caused by not collecting the globals.

- preallocate vectors of known length
- `extend` instead of `append` where the argument is consumable
- turn 2 `push` loops into `extend`s
- create a vector from a function producing one instead of using `extend_from_slice` on it
- consume `modules` when no longer needed
- ~~return an `impl Iterator` from `generate_lto_work`~~
- ~~don't `collect` `globals`, as they are iterated over and consumed right afterwards~~

While I'm hoping it won't cause an OOM anymore, I would still consider this a "high-risk" PR and not roll it up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants