Skip to content

GH-15171: [C++] Pass std::string_view by value#33684

Merged
cyb70289 merged 2 commits intoapache:masterfrom
ucasfl:cpp-string-view
Jan 17, 2023
Merged

GH-15171: [C++] Pass std::string_view by value#33684
cyb70289 merged 2 commits intoapache:masterfrom
ucasfl:cpp-string-view

Conversation

@ucasfl
Copy link
Copy Markdown
Contributor

@ucasfl ucasfl commented Jan 16, 2023

Which issue does this PR close?

Closes #15171.

Rationale for this change

What changes are included in this PR?

Pass std::string_view by value, not by const-ref

Are these changes tested?

Are there any user-facing changes?

No.

@github-actions
Copy link
Copy Markdown

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

In the case of PARQUET issues on JIRA the title also supports:

PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

See also:

@pitrou pitrou changed the title Pass std::string_view by value [C++] Pass std::string_view by value Jan 16, 2023
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we want to enable this by default. You should pass this yourself to CMake using -DCMAKE_EXPORT_COMPILE_COMMANDS=1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a vendored file (as the file path suggests), so we shouldn't do such changes to it. Can you revert them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

@ucasfl ucasfl force-pushed the cpp-string-view branch 2 times, most recently from e1f2491 to 2906008 Compare January 16, 2023 11:01
@pitrou
Copy link
Copy Markdown
Member

pitrou commented Jan 16, 2023

@ursabot please benchmark lang=C++

@ursabot
Copy link
Copy Markdown

ursabot commented Jan 16, 2023

Benchmark runs are scheduled for baseline = 4d9228f and contender = 2906008e491ab5985b26e97781fa750d2c9c4167. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Only ['Python'] langs are supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Finished ⬇️1.59% ⬆️0.03%] test-mac-arm
[Skipped ⚠️ Only ['JavaScript', 'Python', 'R'] langs are supported on ursa-i9-9960x] ursa-i9-9960x
[Finished ⬇️1.0% ⬆️0.4%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] 2906008e test-mac-arm
[Finished] 2906008e ursa-thinkcentre-m75q
[Finished] 4d9228fd ec2-t3-xlarge-us-east-2
[Finished] 4d9228fd test-mac-arm
[Finished] 4d9228fd ursa-i9-9960x
[Finished] 4d9228fd 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

@kou kou changed the title [C++] Pass std::string_view by value GH-15171: [C++] Pass std::string_view by value Jan 17, 2023
@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

⚠️ GitHub issue #15171 has been automatically assigned in GitHub to PR creator.

@cyb70289
Copy link
Copy Markdown
Contributor

Rebased to fix lint error.

@cyb70289
Copy link
Copy Markdown
Contributor

Looks Glib & Ruby CI error is not related? cc @kou
https://github.com/apache/arrow/actions/runs/3935751955/jobs/6731706736#step:10:204

@kou
Copy link
Copy Markdown
Member

kou commented Jan 17, 2023

Not related. It's sometimes happen. I couldn't reproduce it on local environment...

@cyb70289 cyb70289 merged commit 641d1da into apache:master Jan 17, 2023
@ucasfl ucasfl deleted the cpp-string-view branch January 17, 2023 06:21
@ursabot
Copy link
Copy Markdown

ursabot commented Jan 18, 2023

Benchmark runs are scheduled for baseline = 44b0932 and contender = 641d1da. 641d1da 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 ⬇️0.39% ⬆️0.03%] test-mac-arm
[Finished ⬇️0.0% ⬆️1.53%] ursa-i9-9960x
[Finished ⬇️0.56% ⬆️0.37%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] 641d1da6 ec2-t3-xlarge-us-east-2
[Finished] 641d1da6 test-mac-arm
[Finished] 641d1da6 ursa-i9-9960x
[Finished] 641d1da6 ursa-thinkcentre-m75q
[Finished] 44b09323 ec2-t3-xlarge-us-east-2
[Finished] 44b09323 test-mac-arm
[Finished] 44b09323 ursa-i9-9960x
[Finished] 44b09323 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

@westonpace
Copy link
Copy Markdown
Member

@ucasfl thanks for cleaning this up!

@jgehrcke
Copy link
Copy Markdown
Contributor

jgehrcke commented Feb 6, 2023

Some curiosity-driven feedback CC @ucasfl @westonpace @pitrou.

I read https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/ with curiosity and was wondering if this patch here resulted in a measurable performance difference somewhere on the user-facing surface of Arrow.

Before Christmas I build a benchmark that I called dataset-serialize. Among others, it measures the time for dataset CSV serialization, writing to memory (/dev/shm). It also runs on bare metal. Both in combination yields quite some stability.

When this commit landed, said benchmark got faster by (roughly) three percent:

image

The plot/data can be further explored here: https://conbench.ursa.dev/benchmarks/bc6d37ffe2614078814efb01402f64dd/

Of course this is just correlation (once this was merged, the benchmark got a tad faster) and not necessarily causation (for corroborating this I understand too little of the impact of this change). But yeah, it's probably fair to say that it's not unlikely that this change here was responsible for the perf change.

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.

[C++] Pass std::string_view by value, not by const-ref

7 participants