Skip to content

Conversation

@icexelloss
Copy link
Contributor

@icexelloss icexelloss commented Mar 29, 2023

Rationale for this change

I noticed a few places in relation_internal.cc that std::move is used incorrectly.

What changes are included in this PR?

  • Currently, std::move is used when passing arguments to ProcessEmit and ProcessExtensionEmit, however these two methods takes in const reference and therefore the std::move is not needed.
  • (orthogonal) Removed unneeded FromProto from header

Are these changes tested?

With existing tests

Are there any user-facing changes?

No

@icexelloss icexelloss requested a review from westonpace as a code owner March 29, 2023 18:36
@kou kou changed the title MINOR: [C++] Remove std::move when calling ProcessEmit and ProcessExt… MINOR: [C++] Remove std::move when calling ProcessEmit and ProcessExtensionEmit Mar 29, 2023
@icexelloss icexelloss force-pushed the acero-emit-process-move branch from e00d5e5 to fb49302 Compare March 30, 2023 14:41
Result<FieldRef> DirectReferenceFromProto(const substrait::Expression::FieldReference*,
const ExtensionSet&, const ConversionOptions&);

ARROW_ENGINE_EXPORT
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per this comment:
#34627 (comment)

I noticed and removed it here. Although unrelated to the original PR, I figured this is small enough change to piggy back here. If there are objection I can revert this change and put in separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

+1

}
emit_info.expressions = std::move(proj_field_refs);
emit_info.schema = schema(std::move(emit_fields));
return std::move(emit_info);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think std::move of return value is good practice. (Since this prevents NRVO) so I removed them here.

Copy link
Member

Choose a reason for hiding this comment

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

I recall that one of the older compilers (I think mingw) does not recognize that emit_info is the return value because the return type is Result<EmitInfo> and the type of emit_info is EmitInfo. See, for example, https://stackoverflow.com/questions/74459462/why-c-does-not-perform-rvo-to-stdoptional . However, maybe it was one of the older gcc compilers that we no longer support now that we upgraded to C++17.

We should detect it, if it is a problem, if the nightly tests pass. However, the existing convention in the code base is still to use std::move when the return type is Result<T> and the object is T.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. I reverted this.

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Mar 30, 2023
@icexelloss
Copy link
Contributor Author

@westonpace Minor changes to clean up the code a bit - no rush

Copy link
Member

@westonpace westonpace left a comment

Choose a reason for hiding this comment

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

Thanks. I definitely agree with removing std::move when calling ProcessEmit. I'm not sure about the return statement though (see my reply to your comment).

Result<FieldRef> DirectReferenceFromProto(const substrait::Expression::FieldReference*,
const ExtensionSet&, const ConversionOptions&);

ARROW_ENGINE_EXPORT
Copy link
Member

Choose a reason for hiding this comment

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

+1

@icexelloss
Copy link
Contributor Author

icexelloss commented Apr 5, 2023

Thanks. I definitely agree with removing std::move when calling ProcessEmit. I'm not sure about the return statement though (see my reply to your comment).

Got it. I do see in other places where std::move is used for return. I guess it is a larger scope discussion whether we want to change that or not. Will revert that part in this PR.

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Apr 5, 2023
@icexelloss icexelloss force-pushed the acero-emit-process-move branch from b49f836 to e5c2118 Compare April 5, 2023 18:18
@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Apr 5, 2023
Copy link
Member

@westonpace westonpace left a comment

Choose a reason for hiding this comment

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

Thanks for the cleanup.

@westonpace westonpace merged commit a7c4e05 into apache:main Apr 10, 2023
@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting changes Awaiting changes labels Apr 10, 2023
@ursabot
Copy link

ursabot commented Apr 11, 2023

Benchmark runs are scheduled for baseline = 2fe1733 and contender = a7c4e05. a7c4e05 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Finished ⬇️1.25% ⬆️0.03%] test-mac-arm
[Finished ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.37% ⬆️0.03%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] a7c4e05a ec2-t3-xlarge-us-east-2
[Finished] a7c4e05a test-mac-arm
[Finished] a7c4e05a ursa-i9-9960x
[Finished] a7c4e05a ursa-thinkcentre-m75q
[Finished] 2fe17338 ec2-t3-xlarge-us-east-2
[Finished] 2fe17338 test-mac-arm
[Finished] 2fe17338 ursa-i9-9960x
[Finished] 2fe17338 ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

liujiacheng777 pushed a commit to LoongArch-Python/arrow that referenced this pull request May 11, 2023
…ensionEmit (apache#34777)

### Rationale for this change
I noticed a few places in relation_internal.cc that std::move is used incorrectly. 

### What changes are included in this PR?
* Currently, `std::move` is used when passing arguments to `ProcessEmit` and `ProcessExtensionEmit`, however these two methods takes in const reference and therefore the `std::move` is not needed.
* (orthogonal) Removed unneeded `FromProto` from header

### Are these changes tested?
With existing tests

### Are there any user-facing changes?
No

Authored-by: Li Jin <ice.xelloss@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
ArgusLi pushed a commit to Bit-Quill/arrow that referenced this pull request May 15, 2023
…ensionEmit (apache#34777)

### Rationale for this change
I noticed a few places in relation_internal.cc that std::move is used incorrectly. 

### What changes are included in this PR?
* Currently, `std::move` is used when passing arguments to `ProcessEmit` and `ProcessExtensionEmit`, however these two methods takes in const reference and therefore the `std::move` is not needed.
* (orthogonal) Removed unneeded `FromProto` from header

### Are these changes tested?
With existing tests

### Are there any user-facing changes?
No

Authored-by: Li Jin <ice.xelloss@gmail.com>
Signed-off-by: Weston Pace <weston.pace@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants