Skip to content

Add benchmark result#1

Merged
dchristle merged 1 commit intodchristle:ZSTD150from
dongjoon-hyun:SPARK-PR-32826
Jun 17, 2021
Merged

Add benchmark result#1
dchristle merged 1 commit intodchristle:ZSTD150from
dongjoon-hyun:SPARK-PR-32826

Conversation

@dongjoon-hyun
Copy link

No description provided.

@dongjoon-hyun
Copy link
Author

Could you review this, @dchristle ?

@dchristle
Copy link
Owner

LGTM -- running the benchmark on Github Actions took a while yesterday, but for the record, the results were:

Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
Benchmark ZStandardCompressionCodec:                    Best Time(ms)   Avg Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
--------------------------------------------------------------------------------------------------------------------------------------
Compression 10000 times at level 1 without buffer pool            430            684         196          0.0       43017.1       1.0X
Compression 10000 times at level 2 without buffer pool            757            759           2          0.0       75718.0       0.6X
Compression 10000 times at level 3 without buffer pool            934            936           3          0.0       93355.2       0.5X
Compression 10000 times at level 1 with buffer pool               288            289           1          0.0       28845.3       1.5X
Compression 10000 times at level 2 with buffer pool               339            349           5          0.0       33910.8       1.3X
Compression 10000 times at level 3 with buffer pool               505            515           8          0.0       50547.8       0.9X

OpenJDK 64-Bit Server VM 1.8.0_292-b10 on Linux 5.8.0-1033-azure
Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
Benchmark ZStandardCompressionCodec:                        Best Time(ms)   Avg Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
------------------------------------------------------------------------------------------------------------------------------------------
Decompression 10000 times from level 1 without buffer pool            736            739           2          0.0       73575.8       1.0X
Decompression 10000 times from level 2 without buffer pool            736            737           1          0.0       73640.5       1.0X
Decompression 10000 times from level 3 without buffer pool            733            736           3          0.0       73330.2       1.0X
Decompression 10000 times from level 1 with buffer pool               546            548           2          0.0       54563.4       1.3X
Decompression 10000 times from level 2 with buffer pool               546            548           1          0.0       54635.3       1.3X
Decompression 10000 times from level 3 with buffer pool               546            548           1          0.0       54623.8       1.3X
OpenJDK 64-Bit Server VM 11.0.11+9-LTS on Linux 5.8.0-1033-azure
Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
Benchmark ZStandardCompressionCodec:                    Best Time(ms)   Avg Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
--------------------------------------------------------------------------------------------------------------------------------------
Compression 10000 times at level 1 without buffer pool            531            533           3          0.0       53072.6       1.0X
Compression 10000 times at level 2 without buffer pool            598            599           1          0.0       59817.9       0.9X
Compression 10000 times at level 3 without buffer pool            783            784           1          0.0       78346.5       0.7X
Compression 10000 times at level 1 with buffer pool               702            703           2          0.0       70163.3       0.8X
Compression 10000 times at level 2 with buffer pool               768            770           2          0.0       76764.5       0.7X
Compression 10000 times at level 3 with buffer pool               950            952           2          0.0       95046.9       0.6X

OpenJDK 64-Bit Server VM 11.0.11+9-LTS on Linux 5.8.0-1033-azure
Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
Benchmark ZStandardCompressionCodec:                        Best Time(ms)   Avg Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
------------------------------------------------------------------------------------------------------------------------------------------
Decompression 10000 times from level 1 without buffer pool            688            689           1          0.0       68835.7       1.0X
Decompression 10000 times from level 2 without buffer pool            685            691          10          0.0       68455.6       1.0X
Decompression 10000 times from level 3 without buffer pool            689            691           2          0.0       68928.7       1.0X
Decompression 10000 times from level 1 with buffer pool               501            501           1          0.0       50066.6       1.4X
Decompression 10000 times from level 2 with buffer pool               497            505          13          0.0       49741.2       1.4X
Decompression 10000 times from level 3 with buffer pool               499            500           2          0.0       49867.1       1.4X

The actions links are:

https://github.com/dchristle/spark/actions/runs/943948694

https://github.com/dchristle/spark/actions/runs/943949220

The differences between these and the ones in this commit could be due to slight processor differences in the machines selected by Github.

@dchristle dchristle merged commit 4a567dd into dchristle:ZSTD150 Jun 17, 2021
@dongjoon-hyun
Copy link
Author

Ya, due to the difference, usually Relative column is meaningful.

@dongjoon-hyun dongjoon-hyun deleted the SPARK-PR-32826 branch June 17, 2021 16:14
dchristle pushed a commit that referenced this pull request Oct 16, 2022
…ly equivalent children in `RewriteDistinctAggregates`

### What changes were proposed in this pull request?

In `RewriteDistinctAggregates`, when grouping aggregate expressions by function children, treat children that are semantically equivalent as the same.

### Why are the changes needed?

This PR will reduce the number of projections in the Expand operator when there are multiple distinct aggregations with superficially different children. In some cases, it will eliminate the need for an Expand operator.

Example: In the following query, the Expand operator creates 3\*n rows (where n is the number of incoming rows) because it has a projection for each of function children `b + 1`, `1 + b` and `c`.

```
create or replace temp view v1 as
select * from values
(1, 2, 3.0),
(1, 3, 4.0),
(2, 4, 2.5),
(2, 3, 1.0)
v1(a, b, c);

select
  a,
  count(distinct b + 1),
  avg(distinct 1 + b) filter (where c > 0),
  sum(c)
from
  v1
group by a;
```
The Expand operator has three projections (each producing a row for each incoming row):
```
[a#87, null, null, 0, null, UnscaledValue(c#89)], <== projection #1 (for regular aggregation)
[a#87, (b#88 + 1), null, 1, null, null],          <== projection apache#2 (for distinct aggregation of b + 1)
[a#87, null, (1 + b#88), 2, (c#89 > 0.0), null]], <== projection apache#3 (for distinct aggregation of 1 + b)
```
In reality, the Expand only needs one projection for `1 + b` and `b + 1`, because they are semantically equivalent.

With the proposed change, the Expand operator's projections look like this:
```
[a#67, null, 0, null, UnscaledValue(c#69)],  <== projection #1 (for regular aggregations)
[a#67, (b#68 + 1), 1, (c#69 > 0.0), null]],  <== projection apache#2 (for distinct aggregation on b + 1 and 1 + b)
```
With one less projection, Expand produces 2\*n rows instead of 3\*n rows, but still produces the correct result.

In the case where all distinct aggregates have semantically equivalent children, the Expand operator is not needed at all.

Benchmark code in the JIRA (SPARK-40382).

Before the PR:
```
distinct aggregates:                      Best Time(ms)   Avg Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
------------------------------------------------------------------------------------------------------------------------
all semantically equivalent                       14721          14859         195          5.7         175.5       1.0X
some semantically equivalent                      14569          14572           5          5.8         173.7       1.0X
none semantically equivalent                      14408          14488         113          5.8         171.8       1.0X
```
After the PR:
```
distinct aggregates:                      Best Time(ms)   Avg Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
------------------------------------------------------------------------------------------------------------------------
all semantically equivalent                        3658           3692          49         22.9          43.6       1.0X
some semantically equivalent                       9124           9214         127          9.2         108.8       0.4X
none semantically equivalent                      14601          14777         250          5.7         174.1       0.3X
```

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

New unit tests.

Closes apache#37825 from bersprockets/rewritedistinct_issue.

Authored-by: Bruce Robbins <bersprockets@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments