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

[VL] Understanding the Role of builder_helper_functions.sh in Architecture Detection and AVX Impact #8469

Open
rajatma1993 opened this issue Jan 8, 2025 · 3 comments
Labels
bug Something isn't working triage

Comments

@rajatma1993
Copy link

Backend

VL (Velox)

Bug description

Hi @PHILO-HE , Team

Hello,

I need some help in understanding the purpose and usage of the file builder_helper_functions.sh, particularly from the perspective of CPU architecture.

Does this file play a role in detecting the underlying architecture and deciding the build process accordingly?
Specifically, I noticed that it includes checks for AVX. Could someone clarify the reasoning behind introducing AVX in this context?
Does enabling AVX have any significant impact on the performance of Gluten when running on an x86 machine?
Additionally, I reviewed the pull request where the changes related to AVX checks in builder_helper_functions.sh were introduced, but I couldn’t find clear answers or explanations there.

Could anyone provide insights into the purpose and importance of these changes and is there any affect in the build process or performance?

Thank you in advance for your help !!

Spark version

None

Spark configurations

No response

System information

No response

Relevant logs

No response

@rajatma1993 rajatma1993 added bug Something isn't working triage labels Jan 8, 2025
@FelixYBW FelixYBW changed the title Understanding the Role of builder_helper_functions.sh in Architecture Detection and AVX Impact [VL] Understanding the Role of builder_helper_functions.sh in Architecture Detection and AVX Impact Jan 8, 2025
@PHILO-HE
Copy link
Contributor

@rajatma1993, frankly speaking, we have not tested the perf. difference between avx enabled and disabled. There are some native libs that have been optimized with avx, like simdjson lib which is used in native engine. I believe the avx related flag setting for compiler can bring perf. gain to some extent. And we even recommend user to set -march=native to make binary code fully optimized by compiler on user's cpu architecture.

@rajatma1993
Copy link
Author

rajatma1993 commented Jan 10, 2025

Hi @PHILO-HE ,

Thanks For the response !!

I want to clarify my understanding regarding performance improvements related to AVX support. It seems AVX itself doesn’t directly bring performance gains but rather enables native libraries that leverage AVX to provide performance improvements, depending on the underlying machine's capabilities. Is this correct?

Also, regarding the recommendation to set -march=native:

Does this mean users need to explicitly handle this flag during their build process when setting up Gluten?
Is it correct to assume that -march=native is not provided by default?
Additionally, I noticed there was a PR (#7916) that initially introduced the -march=native flag but later commented it out. Could someone explain the significance of this change and why the flag was commented out? Below is the PR I’m referring to for context.

#7916

Also can you help me getting to know files/folders if any, where I can see that what are the Native libs is used in this Project ?

Thanks

@PHILO-HE
Copy link
Contributor

@rajatma1993,

I want to clarify my understanding regarding performance improvements related to AVX support. It seems AVX itself doesn’t directly bring performance gains but rather enables native libraries that leverage AVX to provide performance improvements, depending on the underlying machine's capabilities. Is this correct?

Yes. As I mentioned, some libs like simdjson have some avx-specific code for explicit optimization. And we can also ask compiler to do auto-vectorization by setting O2 or O3 flag along with the avx flag. But it is not enabled in Gluten/Velox.

Also, regarding the recommendation to set -march=native:
Does this mean users need to explicitly handle this flag during their build process when setting up Gluten?
Is it correct to assume that -march=native is not provided by default?

If -march=native is used, we assume that same CPU architecture is used at both compiling time and runtime. According to one user's feedback, the -march=native setting causes fatal error due to the use of some older CPU architecture in their cluster, which is essentially caused by the incompatibility of compiler-optimized binary code. So to avoid such issue, -march=native is not set by default in Gluten. We will provide one option to let user decide the setting.

Also can you help me getting to know files/folders if any, where I can see that what are the Native libs is used in this Project ?

For velox backend, please go to check cpp/ folder where you can see the native libs in using, such as Velox, Arrow, RE2, etc. As you know, Velox is the most important native lib, so you can also check the transitive dependencies from Velox code repo: https://github.com/facebookincubator/velox. You may find any optimization opportunity on native execution from these direct/transitive native dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

2 participants