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

fix: Fix aggregate result error while use gcc11 compile with O2 optim… #12176

Closed

Conversation

lifulong
Copy link
Contributor

@lifulong lifulong commented Jan 26, 2025

Fixes: #11257

I found the wrong result with gcc11 is originated by gcc inline optimize rule by test, use gcc -O1 compile result is ok, use gcc -O2 -fno-inline result is ok, but gcc -O2 result is wrong

three ways can fix this problem in my test:

  1. add __attribute__((noinline)) before function addValues in source file velox/vector/LazyVector.h at line 121, disable inline addValues function
  2. add line asm volatile("" ::: "memory"); before call hook.addValues at line 267 in source file velox/dwio/common/DecoderUtil.h, disable instruction reordering here
  3. store_unaligned values to a tmp array before call hook.addValues at line 267 in source file velox/dwio/common/DecoderUtil.h, same as logic at line 327 in source file velox/dwio/common/DecoderUtil.h

as it show above, there is same logic as fix way 3 at line 327 in source file velox/dwio/common/DecoderUtil.h, so i choose this resolution also, and i have add unit test recording to this problem, make sure the problem fixed.

i think this error may cause by gcc inline and instruction reordering, use error variable values while program exec ? for example we update variable a and use it, after inline and code reorder, variable a update after use, i am not sure here, i have read one article introduce same kind problem cause by gcc inline and code reorder lead to register value mis use.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 26, 2025
Copy link

netlify bot commented Jan 26, 2025

Deploy Preview for meta-velox ready!

Name Link
🔨 Latest commit 60488d7
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/67af3fc33cc03e00096e5545
😎 Deploy Preview https://deploy-preview-12176--meta-velox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@lifulong
Copy link
Contributor Author

can you help review the fix for #11257? @Yuhta @FelixYBW @zml1206

@lifulong
Copy link
Contributor Author

for simplify the test code and test data file, i use only a subset data from #11257 test data, and the data can repeat the problem and verify the fix

@lifulong lifulong force-pushed the fix_wrong_result_use_gcc11 branch from 774e4f4 to b095f86 Compare February 5, 2025 02:48
@lifulong
Copy link
Contributor Author

@majetideepak can you help review this change?

@Yuhta Yuhta added the ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall label Feb 11, 2025
@kgpai
Copy link
Contributor

kgpai commented Feb 12, 2025

@lifulong Can you fix the code format issue ?

@lifulong
Copy link
Contributor Author

lifulong commented Feb 14, 2025

@lifulong Can you fix the code format issue ?

ok , i have fix the code format issue, can you help trigger the check again?

@lifulong lifulong force-pushed the fix_wrong_result_use_gcc11 branch from b095f86 to 60488d7 Compare February 14, 2025 13:06
@facebook-github-bot
Copy link
Contributor

@pedroerp has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@pedroerp merged this pull request in 3b5153f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged ready-to-merge PR that have been reviewed and are ready for merging. PRs with this tag notify the Velox Meta oncall
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diff on parquet filter agg
4 participants