You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/10/22 08:53:51 UTC

[GitHub] [orc] stiga-huang opened a new pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

stiga-huang opened a new pull request #944:
URL: https://github.com/apache/orc/pull/944


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. File a JIRA issue first and use it as a prefix of your PR title, e.g., `ORC-001: Fix ABC`.
     2. Use your PR title to summarize what this PR proposes instead of describing the problem.
     3. Make PR title and description complete because these will be the permanent commit log.
     4. If possible, provide a concise and reproducible example to reproduce the issue for a faster review.
     5. If the PR is unfinished, use GitHub PR Draft feature.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If there is a discussion in the mailing list, please add the link.
   -->
   This PR optimizes the C++ implementation of orc::RleDecoderV2::nextDirect. It provides different methods for different bit sizes, which significantly reduces the instructions and branches. Note that only bit sizes of 4,8,16,24,32,40,48,56,64 are optimized in this PR. bitSize 1 and 2 are skipped since they usually have short runs which won't benefit from loop unrolling. Other deprecated bit sizes, e.g. 3,5,6,7 are also skipped.
   
   When the bit size is specified, we can better exhaust the buffer before calling readByte(). This also improves performance.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   Perf tests show that orc::RleDecoderV2::nextDirect() dominant the time in reading random integers. There are more details in the JIRA description.
   Performance improvement for scanning 1 billion unsigned numbers in different bit sizes:
   
   bitSize | original time(s) | optimized time(s) | speedup
   -- | -- | -- | --
   4 | 5.93 | 3.25 | 1.8246153846
   8 | 6.24 | 2.62 | 2.3816793893
   16 | 7.24 | 2.59 | 2.7953667954
   24 | 8.28 | 3.04 | 2.7236842105
   32 | 9.45 | 2.9 | 3.2586206897
   40 | 10.62 | 3.42 | 3.1052631579
   48 | 11.67 | 3.56 | 3.2780898876
   56 | 12.86 | 4.21 | 3.054631829
   64 | 14.05 | 7.76 | 1.8105670103
   
   Tested on Ubuntu16.04 with a 6 cores CPU (12 virtual cores) and 32GB RAM.
   CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   Add more tests in TestRleDecoder.cc


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun commented on pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #944:
URL: https://github.com/apache/orc/pull/944#issuecomment-958525969


   Thank you, @stiga-huang , @yuruiz , @wgtmac !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun commented on pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #944:
URL: https://github.com/apache/orc/pull/944#issuecomment-958525969


   Thank you, @stiga-huang , @yuruiz , @wgtmac !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] wgtmac commented on pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
wgtmac commented on pull request #944:
URL: https://github.com/apache/orc/pull/944#issuecomment-952463947


   > Thank you, @stiga-huang and @yuruiz .
   > 
   > cc @wgtmac
   
   Thanks for pinging me @dongjoon-hyun . @stiga-huang has already discussed it with @yuruiz and me offline.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun merged pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun merged pull request #944:
URL: https://github.com/apache/orc/pull/944


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun commented on pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #944:
URL: https://github.com/apache/orc/pull/944#issuecomment-951605969


   Thank you, @stiga-huang and @yuruiz .
   
   cc @wgtmac 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun merged pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun merged pull request #944:
URL: https://github.com/apache/orc/pull/944


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun commented on pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #944:
URL: https://github.com/apache/orc/pull/944#issuecomment-952652152


   If this looks good to you, could you approve and merge, @wgtmac ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun merged pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun merged pull request #944:
URL: https://github.com/apache/orc/pull/944


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] dongjoon-hyun commented on pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #944:
URL: https://github.com/apache/orc/pull/944#issuecomment-958525969


   Thank you, @stiga-huang , @yuruiz , @wgtmac !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [orc] stiga-huang commented on pull request #944: ORC-1020: [C++] Optimize RleDecoderV2::nextDirect base on bit sizes

Posted by GitBox <gi...@apache.org>.
stiga-huang commented on pull request #944:
URL: https://github.com/apache/orc/pull/944#issuecomment-953380125


   Thank guys for looking into this! I'll see if we really need manually unrolling the most-inner loop, or we can depend on compilers to optimize this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org