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 copying large ranges of undefmask blocks #58556

Merged
merged 8 commits into from
Mar 15, 2019

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Feb 18, 2019

Hopefully fixes #58523

@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 Feb 18, 2019
@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 18, 2019

@bors try

@bors
Copy link
Contributor

bors commented Feb 18, 2019

⌛ Trying commit e30f55f with merge ab1e694...

bors added a commit that referenced this pull request Feb 18, 2019
Optimize copying large ranges of undefmask blocks

Hopefully fixes #58523
@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 18, 2019

@rust-timer build ab1e694

@rust-timer
Copy link
Collaborator

Success: Queued ab1e694 with parent d215d95, comparison URL.

@bors
Copy link
Contributor

bors commented Feb 18, 2019

☀️ Test successful - checks-travis
State: approved= try=True

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit ab1e694

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 19, 2019

Local tests have shown that my stage 1 compiler needs 8 seconds for

fn main() {
    (&[0; 1 << 28]);
}

while my stage 0 compiler needs 23 seconds.

I'm not sure how to add such a test to the perf test suite without causing significant slowdown of the entire suite.

For smaller arrays (1 << 24) it's not as pronounced, but it's still less than one second consistently with stage 1 and around 2 seconds for stage 0.

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 20, 2019

@bors try

@bors
Copy link
Contributor

bors commented Feb 20, 2019

⌛ Trying commit 5aacd4c5c019169c0d8c77e39e1f78ac0931909d with merge 5f394731e058952a24cf21f80ba4b1bfef28f30f...

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 20, 2019

@rust-timer build 5f394731e058952a24cf21f80ba4b1bfef28f30f

@rust-timer
Copy link
Collaborator

Success: Queued 5f394731e058952a24cf21f80ba4b1bfef28f30f with parent f66e469, comparison URL.

@bors
Copy link
Contributor

bors commented Feb 20, 2019

☀️ Test successful - checks-travis
State: approved= try=True

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 5f394731e058952a24cf21f80ba4b1bfef28f30f

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 21, 2019

perf shows a small (less than 1.5%) but across the board improvement

Once rust-lang/rustc-perf#349 is merged, we should see a big improvement, but I don't see a reason to wait for that.

@joshlf
Copy link
Contributor

joshlf commented Mar 4, 2019

With rust-lang/rustc-perf#349 merged, is this ready to move forward?

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 4, 2019

@bors try

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 4, 2019

@bors ping

@bors
Copy link
Contributor

bors commented Mar 4, 2019

😪 I'm awake I'm awake

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 4, 2019

@bors try

@bors
Copy link
Contributor

bors commented Mar 4, 2019

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

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit af4ce587f67d7256b7a647f1ad5b14e266bdb69a

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 7, 2019

@pnkfelix this is ready for review and perf looks green

pub fn new(size: Size) -> Self {
pub const BLOCK_SIZE: u64 = 64;

pub fn new(size: Size, state: bool) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

I infer that state here is interpreted as { true => defined, false => undefined }, (right?)

You might consider adding a comment above the header saying so. (My initial interpretation of "undef mask" was that if the bit is true, then it is undefined)

// across block boundaries
if new_state {
// set bita..64 to 1
self.blocks[blocka] |= u64::max_value() << bita;
Copy link
Member

@pnkfelix pnkfelix Mar 12, 2019

Choose a reason for hiding this comment

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

(aside: i'm sort of amazed libstd doesn't have named methods for these operations; I would think turning big ranges of bits on or off within a uN (or better still, arbitrary arrays or vectors of [uN]), would be so common as to have higher-level methods than shifts and bitwise-or-masking.)

@pnkfelix
Copy link
Member

Discussed some implementation details with @oli-obk on zulip, namely about the motivation for the run-length encoded form of the undef-mask used in copy_undef_mask.

I'm satisfied that the optimization tends to help more than it hurts.

@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Mar 12, 2019

📌 Commit 2a1eb1c has been approved by pnkfelix

@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 Mar 12, 2019
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Mar 14, 2019
…felix

Optimize copying large ranges of undefmask blocks

Hopefully fixes rust-lang#58523
@bors
Copy link
Contributor

bors commented Mar 14, 2019

⌛ Testing commit 2a1eb1c with merge 8a042506b6c9abd9785883d508244a668250b4cb...

@bors
Copy link
Contributor

bors commented Mar 14, 2019

💔 Test failed - checks-travis

@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 Mar 14, 2019
@rust-highfive
Copy link
Collaborator

The job i686-gnu-nopt of your PR failed on Travis (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.
[02:59:03] test fmt/mod.rs - fmt::LowerExp (line 891) ... ok
[02:59:03] test fmt/mod.rs - fmt::LowerExp (line 899) ... ok
[02:59:03] test fmt/mod.rs - fmt::LowerHex (line 757) ... ok
[02:59:04] test fmt/mod.rs - fmt::LowerHex (line 746) ... ok
The job exceeded the maximum time limit for jobs, and has been terminated.

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)

@kennytm
Copy link
Member

kennytm commented Mar 15, 2019

@bors retry

3 hour timeout?

@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 Mar 15, 2019
@bors
Copy link
Contributor

bors commented Mar 15, 2019

⌛ Testing commit 2a1eb1c with merge 52e8856...

bors added a commit that referenced this pull request Mar 15, 2019
Optimize copying large ranges of undefmask blocks

Hopefully fixes #58523
@bors
Copy link
Contributor

bors commented Mar 15, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: pnkfelix
Pushing 52e8856 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 15, 2019
@bors bors merged commit 2a1eb1c into rust-lang:master Mar 15, 2019
@oli-obk oli-obk deleted the imperative_recursion branch March 16, 2021 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Compiling code hangs compiler
9 participants