Saket Saurabh created QUICKSTEP-59:
--------------------------------------

             Summary: Improve performance of BitVector in Quickstep by 
eliminating branches
                 Key: QUICKSTEP-59
                 URL: https://issues.apache.org/jira/browse/QUICKSTEP-59
             Project: Apache Quickstep
          Issue Type: Improvement
          Components: Query Execution, Utility
            Reporter: Saket Saurabh


The {{setBitRegularVersion()}} of {{BitVector.hpp}} is a critical function that 
is called in various tight loop iterations over storage blocks throughout the 
Quickstep code. This function has a simple purpose of setting a bit value in a 
BitVector to true/false given a boolean argument. However, it has an expensive 
if-else branch that can add a significant penalty at runtime due to branch 
mis-predictions. 


This short PR completely removes branching from the {{setBitRegularVersion()}} 
by replacing the same functionality with a set of bitwise arithmetic 
operations. Given that a branch mis-prediction costs about 10 cycles, the 
branchless code is expected to save those precious 10 cycles at the slight 
expense of 4 additional bitwise operations (an additional 2-4 cycles only, 
given hyper-threading).

*Tests:*
The existing unit tests should already cover the changes introduced by this PR. 
Correctness also verified by comparing TPC-H query output results.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to