Skip to content

[llvm-profdata] Move error handling logic out of normal input's code path #67177

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

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

huangjd
Copy link
Contributor

@huangjd huangjd commented Sep 22, 2023

Based on disassembly and profiling results, it looks like the cost of std::error_code and llvm::ErrorOr<> are non-trivial, as it involves virtual function calls that are not optimized in -O3.

This patch moves error handling logic into the conditional branch in error checking, only generates std::error_code on actual error instead of the default case to generate sampleprof_error::success.

In the next patch I am looking to change the API to uses a plain old enum for error checking instead, because based on profiling results error handling related code accounts for 7-8% of the profile loading time even if there's no error at all.

…path

Based on disassembly and profiling results, it looks like the cost of
std::error_code and llvm::ErrorOr<> are non-trivial, as it involves
virtual function calls that are not optimized in -O3.

This patch moves error handling logic into the conditional branch in
error checking, only generates std::error_code on actual error instead
of the default case to generate sampleprof_error::success.

In the next patch I am looking to change the API to uses a plain old
enum for error checking instead, because based on profiling results
error handling related code accounts for 7-8% of the profile loading
time even if there's no error at all.
Copy link
Contributor

@snehasish snehasish left a comment

Choose a reason for hiding this comment

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

lgtm

@huangjd huangjd merged commit 3a807b5 into llvm:main Sep 25, 2023
@huangjd huangjd deleted the errorOrFix1 branch June 19, 2024 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants