[ 
https://issues.apache.org/jira/browse/HIVE-13306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15550946#comment-15550946
 ] 

Teddy Choi commented on HIVE-13306:
-----------------------------------

{noformat}
Benchmark                                                         Mode  Samples 
       Score       Error  Units
o.a.h.b.v.VectorizedDecimalBench.V1ColAdd128ColBench.bench        avgt      100 
  327816.884 ± 58784.863  ns/op
o.a.h.b.v.VectorizedDecimalBench.V1ColAdd64ColBench.bench         avgt      100 
  227849.687 ± 30660.948  ns/op
o.a.h.b.v.VectorizedDecimalBench.V1ColDiv128By16ColBench.bench    avgt      100 
 1241840.048 ± 51530.545  ns/op
o.a.h.b.v.VectorizedDecimalBench.V1ColDiv128ColBench.bench        avgt      100 
  981592.663 ± 44613.338  ns/op
o.a.h.b.v.VectorizedDecimalBench.V1ColDiv64ColBench.bench         avgt      100 
 1087635.118 ± 50036.593  ns/op
o.a.h.b.v.VectorizedDecimalBench.V1ColMul128ColBench.bench        avgt      100 
  727046.322 ± 79762.130  ns/op
o.a.h.b.v.VectorizedDecimalBench.V1ColMul64ColBench.bench         avgt      100 
  208690.796 ± 52187.887  ns/op
o.a.h.b.v.VectorizedDecimalBench.V1ColSub128ColBench.bench        avgt      100 
  283624.242 ± 45871.509  ns/op
o.a.h.b.v.VectorizedDecimalBench.V1ColSub64ColBench.bench         avgt      100 
  234425.669 ± 32225.245  ns/op
o.a.h.b.v.VectorizedDecimalBench.V1ToString128ColBench.bench      avgt      100 
  308844.565 ± 46089.147  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ColAdd128ColBench.bench        avgt      100 
    5285.747 ±   344.048  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ColAdd64ColBench.bench         avgt      100 
    2979.662 ±   165.400  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ColDiv128By16ColBench.bench    avgt      100 
  169791.489 ± 10768.796  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ColDiv128ColBench.bench        avgt      100 
  450541.606 ± 19502.058  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ColDiv64ColBench.bench         avgt      100 
   19223.414 ±   773.634  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ColMul128ColBench.bench        avgt      100 
   35425.089 ±  1752.701  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ColMul64ColBench.bench         avgt      100 
    2838.959 ±    91.465  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ColSub128ColBench.bench        avgt      100 
    4946.343 ±   298.125  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ColSub64ColBench.bench         avgt      100 
    3098.698 ±   189.485  ns/op
o.a.h.b.v.VectorizedDecimalBench.V2ToString128ColBench.bench      avgt      100 
  277888.247 ± 34990.908  ns/op
{noformat}
Got 2x-100x performance!

> Better Decimal vectorization
> ----------------------------
>
>                 Key: HIVE-13306
>                 URL: https://issues.apache.org/jira/browse/HIVE-13306
>             Project: Hive
>          Issue Type: Bug
>          Components: Hive
>            Reporter: Matt McCline
>            Assignee: Teddy Choi
>            Priority: Critical
>         Attachments: HIVE-13306.1.patch, HIVE-13306.2.patch, 
> HIVE-13306.3.patch
>
>
> Decimal Vectorization Requirements
> •     Today, the LongColumnVector, DoubleColumnVector, BytesColumnVector, 
> TimestampColumnVector classes store the data as primitive Java data types 
> long, double, or byte arrays for efficiency.
> •     DecimalColumnVector is different - it has an array of Object references 
> to HiveDecimal objects.
> •     The HiveDecimal object uses an internal object BigDecimal for its 
> implementation.  Further, BigDecimal itself uses an internal object 
> BigInteger for its implementation, and BigInteger uses an int array.  4 
> objects total.
> •     And, HiveDecimal is an immutable object which means arithmetic and 
> other operations produce new HiveDecimal object with 3 new objects underneath.
> •     A major reason Vectorization is fast is the ColumnVector classes except 
> DecimalColumnVector do not have to allocate additional memory per row.   This 
> avoids memory fragmentation and pressure on the Java Garbage Collector that 
> DecimalColumnVector can generate.  It is very significant.
> •     What can be done with DecimalColumnVector to make it much more 
> efficient?
> o     Design several new decimal classes that allow the caller to manage the 
> decimal storage.
> o     If it takes N int values to store a decimal (e.g. N=1..5), then a new 
> DecimalColumnVector would have an int[] of length N*1024 (where 1024 is the 
> default column vector size).
> o     Why store a decimal in separate int values?
> •     Java does not support 128 bit integers.
> •     Java does not support unsigned integers.
> •     In order to do multiplication of a decimal represented in a long you 
> need twice the storage (i.e. 128 bits).  So you need to represent parts in 32 
> bit integers.
> •     But really since we do not have unsigned, really you can only do 
> multiplications on N-1 bits or 31 bits.
> •     So, 5 ints are needed for decimal storage... of 38 digits.
> o     It makes sense to have just one algorithm for decimals rather than one 
> for HiveDecimal and another for DecimalColumnVector.  So, make HiveDecimal 
> store N int values, too.
> o     A lower level primitive decimal class would accept decimals stored as 
> int arrays and produces results into int arrays.  It would be used by 
> HiveDecimal and DecimalColumnVector.



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

Reply via email to