Skip to content

Conversation

@heary-cao
Copy link
Contributor

@heary-cao heary-cao commented Jul 31, 2018

What changes were proposed in this pull request?

this pr add a configuration parameter to configure the capacity of fast aggregation.
Performance comparison:

 Java HotSpot(TM) 64-Bit Server VM 1.8.0_60-b27 on Windows 7 6.1
 Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
 Aggregate w multiple keys:               Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
 ------------------------------------------------------------------------------------------------
 fasthash = default                            5612 / 5882          3.7         267.6       1.0X
 fasthash = config                             3586 / 3595          5.8         171.0       1.6X

How was this patch tested?

the existed test cases.

@holdensmagicalunicorn
Copy link

@heary-cao, thanks! I am a bot who has found some folks who might be able to help with the review:@rxin, @cloud-fan and @yhuai

@maropu
Copy link
Member

maropu commented Aug 2, 2018

What does the benchmark result suggest? The result should be 1048576 by default?

@heary-cao
Copy link
Contributor Author

@maropu, The test results show that we can make a configuration parameter for the capacity of fast hash. Currently capacity of our fast hash is related to the length of the recorded data. so I'm not sure how much the default value is configured, but it is unreasonable to configure it in CodeGen as a fixed value(int capacity = 1 << 16;).

@heary-cao
Copy link
Contributor Author

cc @maropu

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can see the following code at L226. If a user specify 2^n value (e.g. 1024), it works functionally correct. What happens if a user specified non 2^n value (e.g. 127)?

idx = (idx + 1) & (numBuckets - 1);

@heary-cao heary-cao force-pushed the FastHashCapacity branch 2 times, most recently from 7f40697 to 1428309 Compare August 4, 2018 02:49
@heary-cao
Copy link
Contributor Author

@kiszk, Thank you for your suggestion. I have update it. Can you review it again if you have some time. thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to accept these small values, e.g., 2^1, 2^2, ..? I think these are meaningless...

@maropu
Copy link
Member

maropu commented Aug 6, 2018

cc: @cloud-fan @hvanhovell

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name looks too long. How about spark.sql.codegen.aggregate.map.row.capacitybit or others?

Copy link
Member

@kiszk kiszk Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we describe something about this value? (e.g. bit not for value). Precisely, the actual numBuckets is determined by loadFactor, too.

Can we describe about the default value?

@kiszk
Copy link
Member

kiszk commented Aug 6, 2018

Does this work when we set 30 into the parameter? I am afraid that several arrays with size 0x7fffffff are allocated.

@heary-cao heary-cao force-pushed the FastHashCapacity branch 2 times, most recently from 9984931 to 78cd048 Compare August 6, 2018 11:59
@heary-cao
Copy link
Contributor Author

@kiszk ,I'm not sure how much the maximum is set, and the size of 1G is the maximum value accepted by numBuckets. Of course, buckets is the memory of 8G.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 1 >> 16 -> 1 << 16

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we need to reduce # of characters per line up to 100. IIUC, the number is more than 100.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spark.sql.codegen.aggregate.fastHashMap.capacityBit?

@heary-cao
Copy link
Contributor Author

@kiszk , @cloud-fan
I was on vacation some time ago, I'm sorry to delayed reply.
I have update it, Can you help to review it again if your have some times. thanks.

@kiszk
Copy link
Member

kiszk commented Aug 19, 2018

LGTM, cc @cloud-fan @hvanhovell

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bit -> The bit is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"fasthash = 20"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"fasthash = 16"?

@viirya
Copy link
Member

viirya commented Aug 19, 2018

Minor comments. LGTM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark("Capacity for fast hash aggregate")

@heary-cao heary-cao force-pushed the FastHashCapacity branch 2 times, most recently from eb05b02 to 5ed0fda Compare August 21, 2018 11:32
@heary-cao
Copy link
Contributor Author

cc @cloud-fan @hvanhovell

@cloud-fan
Copy link
Contributor

ok to test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why add it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, update it. thanks.

@SparkQA
Copy link

SparkQA commented Aug 22, 2018

Test build #95107 has finished for PR 21931 at commit 5ed0fda.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we need to add benchmark, we just make the capacity configurable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain how to calculate this valid range?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about the minimum value. The initial configuration is 1. but I agree with @maropu suggestion. e.g., 2^1, 2^2,these are meaningless.
for the maximum is 30, because the integer bit is 31 and the actual numBuckets in fast hash map are determined by loadFactor and loadFactor is 0.5 too.
code is:
private double loadFactor = 0.5;
private int numBuckets = (int) (capacity / loadFactor);

@SparkQA
Copy link

SparkQA commented Aug 23, 2018

Test build #95154 has finished for PR 21931 at commit 03c0a80.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 23, 2018

Test build #95157 has finished for PR 21931 at commit af2078c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 24, 2018

Test build #95190 has finished for PR 21931 at commit 6abeb06.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@heary-cao
Copy link
Contributor Author

cc @cloud-fan @hvanhovell

@maropu
Copy link
Member

maropu commented Aug 25, 2018

LGTM

@kiszk
Copy link
Member

kiszk commented Aug 25, 2018

LGTM again

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@asfgit asfgit closed this in 6193a20 Aug 27, 2018
bogdanrdc pushed a commit to bogdanrdc/spark that referenced this pull request Aug 28, 2018
… to configure the capacity of fast aggregation.

## What changes were proposed in this pull request?

this pr add a configuration parameter to configure the capacity of fast aggregation.
Performance comparison:

```
 Java HotSpot(TM) 64-Bit Server VM 1.8.0_60-b27 on Windows 7 6.1
 Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
 Aggregate w multiple keys:               Best/Avg Time(ms)    Rate(M/s)   Per Row(ns)   Relative
 ------------------------------------------------------------------------------------------------
 fasthash = default                            5612 / 5882          3.7         267.6       1.0X
 fasthash = config                             3586 / 3595          5.8         171.0       1.6X

```

## How was this patch tested?
the existed test cases.

Closes apache#21931 from heary-cao/FastHashCapacity.

Authored-by: caoxuewen <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants