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

Box `DiagnosticBuilder`. #64374

Merged
merged 1 commit into from Sep 14, 2019

Conversation

@nnethercote
Copy link
Contributor

commented Sep 11, 2019

It's a large type -- 176 bytes on 64-bit. And it's passed around and
returned from a lot of functions, including within PResult.

This commit boxes it, which reduces memory traffic. In particular,
PResult shrinks to 16 bytes in the best case; this reduces instruction
counts by up to 2% on various workloads. The commit touches a lot of
lines but it's almost all trivial plumbing changes.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Sep 11, 2019

r? @zackmdavis

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

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

commented Sep 11, 2019

@bors try

@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2019

⌛️ Trying commit 176bc8c with merge 10e8cb2...

bors added a commit that referenced this pull request Sep 11, 2019
Auto merge of #64374 - nnethercote:box-DiagnosticBuilder, r=<try>
Box `DiagnosticBuilder`.

It's a large type -- 176 bytes on 64-bit. And it's passed around and
returned from a lot of functions, including within `PResult`.

This commit boxes it, which reduces memory traffic. In particular,
`PResult` shrinks to 16 bytes in the best case; this reduces instruction
counts by up to 2% on various workloads. The commit touches a lot of
lines but it's almost all trivial plumbing changes.
@Centril

This comment has been minimized.

Copy link
Member

commented Sep 11, 2019

Is there a process by which you selected these specific cases to do the boxing?
Would it be detrimental to apply this change inside the DiagnosticBuilder type instead?

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

commented Sep 11, 2019

My strategy was "gotta box 'em all", because there's not much point only boxing some, and if you did, there isn't an obvious dividing line between boxed and non-boxed.

Boxing within DiagnosticBuilder would be possible. It would make DiagnosticBuilder itself a bit more complicated, but would avoid the sweeping DiagnosticBuilder to Box<DiagnosticBuilder> changes in the current commit.

@Centril

This comment has been minimized.

Copy link
Member

commented Sep 11, 2019

Boxing within DiagnosticBuilder would be possible. It would make DiagnosticBuilder itself a bit more complicated, but would avoid the sweeping DiagnosticBuilder to Box<DiagnosticBuilder> changes in the current commit.

The main reason I would prefer to do an internal change is to make the developer UX better so that that "doing the wrong thing" is not possible here. I think I'd personally forget about your PR after a while and forget to do the manual boxing so not having to think about it would be neat.

cc also @estebank

@petrochenkov

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2019

Why is it memcpy'ed in the first place?
It looks large enough to be passed and returned by pointer in ABI.

Is it something that is supposed to be addressed by RVO, which rustc doesn't always do when it should right now?
If that's the case, then I'd prefer to make the box internal so it could be removed without touching all the users when RVO is fixed.

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

commented Sep 11, 2019

The job mingw-check of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-09-11T10:45:58.4130118Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-11T10:45:59.1803827Z ##[command]git config gc.auto 0
2019-09-11T10:45:59.1807473Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-11T10:45:59.1809463Z ##[command]git config --get-all http.proxy
2019-09-11T10:45:59.1813653Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/64374/merge:refs/remotes/pull/64374/merge
---
2019-09-11T10:57:50.5276168Z configure: build.locked-deps    := True
2019-09-11T10:57:50.5276383Z configure: llvm.ccache          := sccache
2019-09-11T10:57:50.5276860Z configure: build.cargo-native-static := True
2019-09-11T10:57:50.5277275Z configure: dist.missing-tools   := True
2019-09-11T10:57:50.5277762Z configure: build.configure-args := ['--enable-sccache', '--disable-manage-submodu ...
2019-09-11T10:57:50.5279622Z configure: writing `config.toml` in current directory
2019-09-11T10:57:50.5279955Z configure: 
2019-09-11T10:57:50.5280630Z configure: run `python /checkout/x.py --help`
2019-09-11T10:57:50.5280946Z configure: 
---
2019-09-11T11:03:17.5879091Z == clock drift check ==
2019-09-11T11:03:17.5901063Z   local time: Wed Sep 11 11:03:17 UTC 2019
2019-09-11T11:03:17.7394505Z   network time: Wed, 11 Sep 2019 11:03:17 GMT
2019-09-11T11:03:17.7398405Z == end clock drift check ==
2019-09-11T11:03:18.8417134Z ##[error]Bash exited with code '1'.
2019-09-11T11:03:18.8500637Z ##[section]Starting: Checkout
2019-09-11T11:03:18.8503320Z ==============================================================================
2019-09-11T11:03:18.8503401Z Task         : Get sources
2019-09-11T11:03:18.8503448Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

commented Sep 11, 2019

Indeed, and I would actually look at boxing the Diagnostic internally instead, or maybe just reducing it's size via some other optimizations.

@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2019

☀️ Try build successful - checks-azure
Build commit: 10e8cb2

Box `DiagnosticBuilder`.
It's a large type -- 176 bytes on 64-bit. And it's passed around and
returned from a lot of functions, including within PResult.

This commit boxes it, which reduces memory traffic. In particular,
`PResult` shrinks to 16 bytes in the best case; this reduces instruction
counts by up to 2% on various workloads.

@nnethercote nnethercote force-pushed the nnethercote:box-DiagnosticBuilder branch from 176bc8c to 2fcd870 Sep 11, 2019

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

commented Sep 11, 2019

I have updated the code to use an internal box. It made the patch much less invasive -- thanks for the suggestion, @Centril.

I don't know why RVO isn't being applied. I just go where the profiler tells me to, and it told me that lots of memcpys were happening because of PResult. I have added a comment about this.

I also fixed the mingw failure.

@bors try

@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2019

⌛️ Trying commit 2fcd870 with merge 25dba65...

bors added a commit that referenced this pull request Sep 11, 2019
Auto merge of #64374 - nnethercote:box-DiagnosticBuilder, r=<try>
Box `DiagnosticBuilder`.

It's a large type -- 176 bytes on 64-bit. And it's passed around and
returned from a lot of functions, including within `PResult`.

This commit boxes it, which reduces memory traffic. In particular,
`PResult` shrinks to 16 bytes in the best case; this reduces instruction
counts by up to 2% on various workloads. The commit touches a lot of
lines but it's almost all trivial plumbing changes.
@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2019

⌛️ Trying commit 2fcd870 with merge f81c392...

bors added a commit that referenced this pull request Sep 12, 2019
Auto merge of #64374 - nnethercote:box-DiagnosticBuilder, r=<try>
Box `DiagnosticBuilder`.

It's a large type -- 176 bytes on 64-bit. And it's passed around and
returned from a lot of functions, including within `PResult`.

This commit boxes it, which reduces memory traffic. In particular,
`PResult` shrinks to 16 bytes in the best case; this reduces instruction
counts by up to 2% on various workloads. The commit touches a lot of
lines but it's almost all trivial plumbing changes.
@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2019

☀️ Try build successful - checks-azure
Build commit: f81c392

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

commented Sep 12, 2019

@rust-timer

This comment has been minimized.

Copy link

commented Sep 12, 2019

Success: Queued f81c392 with parent f0b58fc, comparison URL.

@rust-timer

This comment has been minimized.

Copy link

commented Sep 12, 2019

Finished benchmarking try commit f81c392, comparison URL.

@nnethercote

This comment has been minimized.

Copy link
Contributor Author

commented Sep 12, 2019

The perf results look good, reducing instruction counts by up to 2.6%.

@zackmdavis

This comment has been minimized.

Copy link
Member

commented Sep 14, 2019

Great! 💖

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Sep 14, 2019

📌 Commit 2fcd870 has been approved by zackmdavis

Centril added a commit to Centril/rust that referenced this pull request Sep 14, 2019
Rollup merge of rust-lang#64374 - nnethercote:box-DiagnosticBuilder, …
…r=zackmdavis

Box `DiagnosticBuilder`.

It's a large type -- 176 bytes on 64-bit. And it's passed around and
returned from a lot of functions, including within `PResult`.

This commit boxes it, which reduces memory traffic. In particular,
`PResult` shrinks to 16 bytes in the best case; this reduces instruction
counts by up to 2% on various workloads. The commit touches a lot of
lines but it's almost all trivial plumbing changes.
bors added a commit that referenced this pull request Sep 14, 2019
Auto merge of #64449 - Centril:rollup-ybq0h5v, r=Centril
Rollup of 17 pull requests

Successful merges:

 - #64116 (Fix minor typo in docs.)
 - #64290 (Provide a span if main function is not present in crate)
 - #64302 (Shrink `ObligationCauseCode`)
 - #64372 (use randSecure and randABytes)
 - #64374 (Box `DiagnosticBuilder`.)
 - #64375 (Fast path for vec.clear/truncate )
 - #64378 (Fix inconsistent link formatting.)
 - #64384 (Trim rustc-workspace-hack)
 - #64393 ( declare EnvKey before use to fix build error)
 - #64420 (Inline `mark_neighbours_as_waiting_from`.)
 - #64422 (Remove raw string literal quotes from error index descriptions)
 - #64423 (Add self to .mailmap)
 - #64424 (Fix false "never constructed" warnings for `Self::` variant paths)
 - #64425 (typo fix)
 - #64431 (fn ptr is structural match)
 - #64435 (codegen: use "_N" (like for other locals) instead of "argN", for argument names.)
 - #64439 (fix #64430, confusing `owned_box` error message in no_std build)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Sep 14, 2019
Rollup merge of rust-lang#64374 - nnethercote:box-DiagnosticBuilder, …
…r=zackmdavis

Box `DiagnosticBuilder`.

It's a large type -- 176 bytes on 64-bit. And it's passed around and
returned from a lot of functions, including within `PResult`.

This commit boxes it, which reduces memory traffic. In particular,
`PResult` shrinks to 16 bytes in the best case; this reduces instruction
counts by up to 2% on various workloads. The commit touches a lot of
lines but it's almost all trivial plumbing changes.
bors added a commit that referenced this pull request Sep 14, 2019
Auto merge of #64452 - Centril:rollup-z101tu8, r=Centril
Rollup of 17 pull requests

Successful merges:

 - #63846 (Added table containing the system calls used by Instant and SystemTime.)
 - #64116 (Fix minor typo in docs.)
 - #64290 (Provide a span if main function is not present in crate)
 - #64302 (Shrink `ObligationCauseCode`)
 - #64372 (use randSecure and randABytes)
 - #64374 (Box `DiagnosticBuilder`.)
 - #64375 (Fast path for vec.clear/truncate )
 - #64378 (Fix inconsistent link formatting.)
 - #64384 (Trim rustc-workspace-hack)
 - #64393 ( declare EnvKey before use to fix build error)
 - #64420 (Inline `mark_neighbours_as_waiting_from`.)
 - #64422 (Remove raw string literal quotes from error index descriptions)
 - #64423 (Add self to .mailmap)
 - #64425 (typo fix)
 - #64431 (fn ptr is structural match)
 - #64435 (codegen: use "_N" (like for other locals) instead of "argN", for argument names.)
 - #64439 (fix #64430, confusing `owned_box` error message in no_std build)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Sep 14, 2019
Rollup merge of rust-lang#64374 - nnethercote:box-DiagnosticBuilder, …
…r=zackmdavis

Box `DiagnosticBuilder`.

It's a large type -- 176 bytes on 64-bit. And it's passed around and
returned from a lot of functions, including within `PResult`.

This commit boxes it, which reduces memory traffic. In particular,
`PResult` shrinks to 16 bytes in the best case; this reduces instruction
counts by up to 2% on various workloads. The commit touches a lot of
lines but it's almost all trivial plumbing changes.
bors added a commit that referenced this pull request Sep 14, 2019
Auto merge of #64456 - Centril:rollup-ytqdwaq, r=Centril
Rollup of 17 pull requests

Successful merges:

 - #63846 (Added table containing the system calls used by Instant and SystemTime.)
 - #64116 (Fix minor typo in docs.)
 - #64203 (A few cosmetic improvements to code & comments in liballoc and libcore)
 - #64302 (Shrink `ObligationCauseCode`)
 - #64372 (use randSecure and randABytes)
 - #64374 (Box `DiagnosticBuilder`.)
 - #64375 (Fast path for vec.clear/truncate )
 - #64378 (Fix inconsistent link formatting.)
 - #64384 (Trim rustc-workspace-hack)
 - #64393 ( declare EnvKey before use to fix build error)
 - #64420 (Inline `mark_neighbours_as_waiting_from`.)
 - #64422 (Remove raw string literal quotes from error index descriptions)
 - #64423 (Add self to .mailmap)
 - #64425 (typo fix)
 - #64431 (fn ptr is structural match)
 - #64435 (codegen: use "_N" (like for other locals) instead of "argN", for argument names.)
 - #64439 (fix #64430, confusing `owned_box` error message in no_std build)

Failed merges:

r? @ghost

@bors bors merged commit 2fcd870 into rust-lang:master Sep 14, 2019

5 checks passed

homu Test successful
Details
pr Build #20190911.35 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 (LinuxTools) LinuxTools succeeded
Details

@nnethercote nnethercote deleted the nnethercote:box-DiagnosticBuilder branch Sep 14, 2019

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