3

Replace Copy/Clone compiler magic on arrays with library impls by bstrie · Pull...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/86041
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conversation

Copy link

Contributor

bstrie commented on Jun 5

With const generics the compiler no longer needs to fake these impls.

Copy link

Collaborator

rust-highfive commented on Jun 5

r? @joshtriplett

(rust-highfive has picked a reviewer for you, use r? to override)

This comment has been hidden.

Copy link

Contributor

tmiasko commented on Jun 7

The code building the clone shim for array can be removed now as well, right?

Copy link

Contributor

Author

bstrie commented on Jun 12

I've addressed the feedback and this is ready for review.

Copy link

Contributor

bors commented on Aug 18

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

Copy link

Member

wesleywiser commented on Sep 2

Hi @bstrie! Would you mind rebasing this PR and resolving the merge conflict so we can do a perf run? Assuming that does not reveal any issues, I think we're about ready to merge this.

Copy link

Contributor

@jackh726 jackh726 left a comment

This LGTM to me on compiler and traits changes.

Copy link

Member

JohnCSimon commented on Sep 20

Ping from triage:
@bstrie can you please resolve the merge conflicts?

Copy link

Member

joshtriplett commented on Oct 4

This seems reasonable to me, once the merge conflicts are resolved and a perf run comes back without regressions.

Copy link

Contributor

bors commented 14 days ago

sunny Try build successful - checks-actions
Build commit: 78d6575 (78d657592a19e656b8e8819fea9cb5eca34149f0)

Copy link

Collaborator

rust-timer commented 14 days ago

Copy link

Collaborator

rust-timer commented 13 days ago

Finished benchmarking commit (78d6575): comparison url.

Summary: This change led to moderate relevant mixed results shrug in compiler performance.

  • Moderate improvement in instruction counts (up to -1.2% on incr-unchanged builds of deeply-nested)
  • Moderate regression in instruction counts (up to 1.4% on full builds of cranelift-codegen)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf +perf-regression

Copy link

Contributor

jackh726 commented 13 days ago

edited

That looks better...mostly a bit more time spent in LLVM (not completely unexpected). Now this is even a slight improvement in a couple benchmarks.

With the latest results, the balance has shifted away from an intrinsic or some other magic being a good idea, imo.

I think performance results are definitely closer to being acceptable here, I'm OK with not bothering with trying out the shim approach or hand-coding it to generate better IR.

Copy link

Contributor

a1phyr commented 13 days ago

Maybe we could write a simple specialized function for clone that would be easier for LLVM to optimize on release and would require less codegen on debug (reusing the code for Guard):

fn clone(&self) -> Self {
    let mut array = MaybeUninit::uninit_array::<N>();
    let mut guard = Guard { array_mut: &mut array, initialized: 0 };

    for i in 0..N {
        let item = src[i].clone();
        guard.array_mut[i].write(item);
        guard.initialized = i;

    }

    mem::forget(guard);
    unsafe { MaybeUninit::array_assume_init(array) }
}

Copy link

Contributor

jackh726 commented 13 days ago

Maybe we could write a simple specialized function for clone that would be easier for LLVM to optimize on release and would require less codegen on debug (reusing the code for Guard):

Imo, i think this would better be left as followup.

Copy link

Contributor

jackh726 commented 13 days ago

Okay, given previous review from @joshtriplett, previous discussion during a compiler meeting, and perf review by @Mark-Simulacrum, and my own review of compiler/traits changes, I'm going to go ahead and @bors r+

Copy link

Contributor

bors commented 13 days ago

pushpin Commit 61b1394 has been approved by jackh726

Copy link

Contributor

bors commented 13 days ago

hourglass Testing commit 61b1394 with merge fc59b7e...

Copy link

Collaborator

rust-log-analyzer commented 13 days ago

The job x86_64-msvc-cargo failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

Copy link

Contributor

bors commented 13 days ago

broken_heart Test failed - checks-actions

Copy link

Contributor

jackh726 commented 13 days ago

@bors retry

Copy link

Contributor

bors commented 13 days ago

hourglass Testing commit 61b1394 with merge d608229...

Copy link

Contributor

bors commented 13 days ago

sunny Test successful - checks-actions
Approved by: jackh726
Pushing d608229 to master...

Copy link

Collaborator

rust-timer commented 13 days ago

Finished benchmarking commit (d608229): comparison url.

Summary: This change led to moderate relevant mixed results shrug in compiler performance.

  • Moderate improvement in instruction counts (up to -1.2% on incr-unchanged builds of deeply-nested)
  • Moderate regression in instruction counts (up to 1.0% on full builds of cranelift-codegen)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK