Enable JIT compilation for more expressions#70598
Enable JIT compilation for more expressions#70598nickitat merged 46 commits intoClickHouse:masterfrom
Conversation
|
First prepare data CREATE TABLE jit_test (
a UInt64,
b UInt64,
c UInt64,
d UInt64,
e UInt64,
f UInt64,
g UInt64,
h UInt64,
i UInt64,
j UInt64
) Engine = Memory
INSERT INTO jit_test
SELECT
number,
number,
number,
number,
number,
number,
number,
number,
number,
number
FROM
system.numbers
LIMIT 100000000For SELECT abs(-a) / abs(b) + abs(c) / abs(d) + abs(-e) / abs(f) + abs(g) / abs(h) + abs(-i) / abs(j) FROM jit_test SETTINGS compile_expressions = 0 format Null;
0 rows in set. Elapsed: 0.607 sec. Processed 100.00 million rows, 8.00 GB (164.87 million rows/s., 13.19 GB/s.)
SELECT abs(-a) / abs(b) + abs(c) / abs(d) + abs(-e) / abs(f) + abs(g) / abs(h) + abs(-i) / abs(j) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
0 rows in set. Elapsed: 0.159 sec. Processed 100.00 million rows, 8.00 GB (628.62 million rows/s., 50.29 GB/s.) For SELECT bitCount(a) + bitCount(b) + bitCount(c) + bitCount(d) + bitCount(e) + bitCount(f) + bitCount(g)+ bitCount(h)+ bitCount(i) + bitCount(j) FROM jit_test SETTINGS compile_expressions = 0 format Null;
0 rows in set. Elapsed: 0.281 sec. Processed 100.00 million rows, 8.00 GB (355.82 million rows/s., 28.47 GB/s.)
SELECT bitCount(a) + bitCount(b) + bitCount(c) + bitCount(d) + bitCount(e) + bitCount(f) + bitCount(g)+ bitCount(h)+ bitCount(i) + bitCount(j) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
0 rows in set. Elapsed: 0.137 sec. Processed 100.00 million rows, 8.00 GB (728.95 million rows/s., 58.32 GB/s.) |
|
This is an automated comment for commit 0e82fb8 with description of existing statuses. It's updated for the latest CI running ✅ Click here to open a full report in a separate page Successful checks
|
|
For
without compilation: SELECT sign(a) + sign(b) + sign(c) + sign(d) + sign(e) + sign(f) + sign(g) + sign(h) + sign(i) + sign(j) FROM jit_test SETTINGS compile_expressions = 0 format Null;
localhost:9001, queries: 20, QPS: 3.522, RPS: 352227623.681, MiB/s: 26872.835, result RPS: 0.000, result MiB/s: 0.000
with compilation: SELECT sign(a) + sign(b) + sign(c) + sign(d) + sign(e) + sign(f) + sign(g) + sign(h) + sign(i) + sign(j) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
localhost:9001, queries: 20, QPS: 7.372, RPS: 737213493.089, MiB/s: 56244.926, result RPS: 0.000, result MiB/s: 0.000.
|
|
For comparison functions, execution with JIT is slightly slower. SELECT equals(a, b/g) + less(c, d/g) + greater(e/g, f) FROM jit_test SETTINGS compile_expressions = 0 format Null;
localhost:9001, queries: 20, QPS: 4.426, RPS: 442635961.679, MiB/s: 23639.311, result RPS: 0.000, result MiB/s: 0.000.
SELECT equals(a, b/g) + less(c, d/g) + greater(e/g, f) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
localhost:9001, queries: 20, QPS: 4.387, RPS: 438709117.961, MiB/s: 23429.595, result RPS: 0.000, result MiB/s: 0.000.For SELECT isNotNull(a::Nullable(UInt64)) + isNotNull(b::Nullable(UInt64)) + isNotNull(c::Nullable(UInt64)) + isNotNull(d::Nullable(UInt64)) + isNotNull(e::Nullable(UInt64)) + isNotNull(f::Nullable(UInt64)) + isNotNull(g::Nullable(UInt64)) FROM jit_test SETTINGS compile_expressions = 0 format Null;
0 rows in set. Elapsed: 0.120 sec. Processed 100.00 million rows, 5.60 GB (836.18 million rows/s., 46.83 GB/s.)
SELECT isNotNull(a::Nullable(UInt64)) + isNotNull(b::Nullable(UInt64)) + isNotNull(c::Nullable(UInt64)) + isNotNull(d::Nullable(UInt64)) + isNotNull(e::Nullable(UInt64)) + isNotNull(f::Nullable(UInt64)) + isNotNull(g::Nullable(UInt64)) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
0 rows in set. Elapsed: 0.064 sec. Processed 100.00 million rows, 5.60 GB (1.55 billion rows/s., 87.00 GB/s.)For SELECT assumeNotNull(a::Nullable(UInt64)) + assumeNotNull(b::Nullable(UInt64)) + assumeNotNull(c::Nullable(UInt64)) + assumeNotNull(d::Nullable(UInt64)) + assumeNotNull(e::Nullable(UInt64)) + assumeNotNull(f::Nullable(UInt64)) + assumeNotNull(g::Nullable(UInt64)) FROM jit_test SETTINGS compile_expressions = 0 format Null;
0 rows in set. Elapsed: 0.166 sec. Processed 100.00 million rows, 5.60 GB (602.55 million rows/s., 33.74 GB/s.)
SELECT assumeNotNull(a::Nullable(UInt64)) + assumeNotNull(b::Nullable(UInt64)) + assumeNotNull(c::Nullable(UInt64)) + assumeNotNull(d::Nullable(UInt64)) + assumeNotNull(e::Nullable(UInt64)) + assumeNotNull(f::Nullable(UInt64)) + assumeNotNull(g::Nullable(UInt64)) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
0 rows in set. Elapsed: 0.066 sec. Processed 100.00 million rows, 5.60 GB (1.51 billion rows/s., 84.78 GB/s.) For SELECT and(a::Nullable(UInt64), b::Nullable(UInt64)) + and(c::Nullable(UInt64), d::Nullable(UInt64)) + and(e::Nullable(UInt64), f::Nullable(UInt64)) + g::Nullable(UInt64) FROM jit_test SETTINGS compile_expressions = 0 format Null;
localhost:9001, queries: 20, QPS: 4.661, RPS: 466084590.184, MiB/s: 24891.603, result RPS: 0.000, result MiB/s: 0.000.
SELECT and(a::Nullable(UInt64), b::Nullable(UInt64)) + and(c::Nullable(UInt64), d::Nullable(UInt64)) + and(e::Nullable(UInt64), f::Nullable(UInt64)) + g::Nullable(UInt64) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
localhost:9001, queries: 20, QPS: 5.143, RPS: 514327996.044, MiB/s: 27468.078, result RPS: 0.000, result MiB/s: 0.000.For SELECT or(a::Nullable(UInt64), b::Nullable(UInt64)) + or(c::Nullable(UInt64), d::Nullable(UInt64)) + or(e::Nullable(UInt64), f::Nullable(UInt64)) + g::Nullable(UInt64) FROM jit_test SETTINGS compile_expressions = 0 format Null;
localhost:9001, queries: 20, QPS: 6.569, RPS: 656907149.117, MiB/s: 35082.627, result RPS: 0.000, result MiB/s: 0.000.
SELECT or(a::Nullable(UInt64), b::Nullable(UInt64)) + or(c::Nullable(UInt64), d::Nullable(UInt64)) + or(e::Nullable(UInt64), f::Nullable(UInt64)) + g::Nullable(UInt64) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
localhost:9001, queries: 20, QPS: 7.087, RPS: 708686555.439, MiB/s: 37847.945, result RPS: 0.000, result MiB/s: 0.000.For SELECT xor(a::Nullable(UInt64), b::Nullable(UInt64)) + xor(c::Nullable(UInt64), d::Nullable(UInt64)) + xor(e::Nullable(UInt64), f::Nullable(UInt64)) + g::Nullable(UInt64) FROM jit_test SETTINGS compile_expressions = 0 format Null;
localhost:9001, queries: 20, QPS: 8.167, RPS: 816676282.063, MiB/s: 43615.219, result RPS: 0.000, result MiB/s: 0.000.
SELECT xor(a::Nullable(UInt64), b::Nullable(UInt64)) + xor(c::Nullable(UInt64), d::Nullable(UInt64)) + xor(e::Nullable(UInt64), f::Nullable(UInt64)) + g::Nullable(UInt64) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null
localhost:9001, queries: 20, QPS: 12.297, RPS: 1229676512.222, MiB/s: 65671.811, result RPS: 0.000, result MiB/s: 0.000. |
|
For SELECT isNull(a::Nullable(UInt64)) + isNull(b::Nullable(UInt64)) + isNull(c::Nullable(UInt64)) + isNull(d::Nullable(UInt64)) + isNull(e::Nullable(UInt64)) + isNull(f::Nullable(UInt64)) + isNull(g::Nullable(UInt64)) FROM jit_test SETTINGS compile_expressions = 0 format Null;
0 rows in set. Elapsed: 0.118 sec. Processed 100.00 million rows, 5.60 GB (849.83 million rows/s., 47.59 GB/s.)
SELECT isNull(a::Nullable(UInt64)) + isNull(b::Nullable(UInt64)) + isNull(c::Nullable(UInt64)) + isNull(d::Nullable(UInt64)) + isNull(e::Nullable(UInt64)) + isNull(f::Nullable(UInt64)) + isNull(g::Nullable(UInt64)) FROM jit_test SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
0 rows in set. Elapsed: 0.063 sec. Processed 100.00 million rows, 5.60 GB (1.60 billion rows/s., 89.57 GB/s.) For SELECT modulo(a::Nullable(UInt64), b::Nullable(UInt64)) + modulo(c::Nullable(UInt64), d::Nullable(UInt64)) + modulo(e::Nullable(UInt64), f::Nullable(UInt64)) FROM jit_test where a != 0 SETTINGS compile_expressions = 0 format Null
0 rows in set. Elapsed: 0.501 sec. Processed 200.00 million rows, 9.60 GB (399.09 million rows/s., 19.16 GB/s.)
SELECT modulo(a::Nullable(UInt64), b::Nullable(UInt64)) + modulo(c::Nullable(UInt64), d::Nullable(UInt64)) + modulo(e::Nullable(UInt64), f::Nullable(UInt64)) FROM jit_test where a != 0 SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
0 rows in set. Elapsed: 0.198 sec. Processed 200.00 million rows, 9.60 GB (1.01 billion rows/s., 48.55 GB/s.)For SELECT pmod(a::Nullable(UInt64), b::Nullable(UInt64)) + pmod(c::Nullable(UInt64), d::Nullable(UInt64)) + pmod(e::Nullable(UInt64), f::Nullable(UInt64)) FROM jit_test where a != 0 SETTINGS compile_expressions = 0 format Null
0 rows in set. Elapsed: 0.594 sec. Processed 200.00 million rows, 9.60 GB (336.52 million rows/s., 16.15 GB/s.)
SELECT pmod(a::Nullable(UInt64), b::Nullable(UInt64)) + pmod(c::Nullable(UInt64), d::Nullable(UInt64)) + pmod(e::Nullable(UInt64), f::Nullable(UInt64)) FROM jit_test where a != 0 SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
0 rows in set. Elapsed: 0.279 sec. Processed 200.00 million rows, 9.60 GB (717.50 million rows/s., 34.44 GB/s.) For SELECT modulo(toInt64(a), toInt64(b)) + modulo(toInt64(c), toInt64(d)) + modulo(toInt64(e), toInt64(f)) FROM jit_test where a != 0 SETTINGS compile_expressions = 0 format Null;
0 rows in set. Elapsed: 0.365 sec. Processed 100.00 million rows, 4.80 GB (273.62 million rows/s., 13.13 GB/s.)
SELECT modulo(toInt64(a), toInt64(b)) + modulo(toInt64(c), toInt64(d)) + modulo(toInt64(e), toInt64(f)) FROM jit_test where a != 0 SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
0 rows in set. Elapsed: 0.138 sec. Processed 100.00 million rows, 4.80 GB (723.66 million rows/s., 34.74 GB/s.) For SELECT plus(identity(cast(a as Nullable(Int64))), identity(cast(b as Nullable(Int64)))) + plus(identity(cast(c as Nullable(Int64))), identity(cast(d as Nullable(Int64)))) + plus(identity(cast(e as Nullable(Int64))), identity(cast(f as Nullable(Int64)))) FROM jit_test where a != 0 SETTINGS compile_expressions = 0 format Null;
0 rows in set. Elapsed: 0.373 sec. Processed 100.00 million rows, 4.80 GB (268.40 million rows/s., 12.88 GB/s.)
SELECT plus(identity(cast(a as Nullable(Int64))), identity(cast(b as Nullable(Int64)))) + plus(identity(cast(c as Nullable(Int64))), identity(cast(d as Nullable(Int64)))) + plus(identity(cast(e as Nullable(Int64))), identity(cast(f as Nullable(Int64)))) FROM jit_test where a != 0 SETTINGS compile_expressions = 1, min_count_to_compile_expression = 0 format Null;
0 rows in set. Elapsed: 0.287 sec. Processed 100.00 million rows, 4.80 GB (348.48 million rows/s., 16.73 GB/s.) |
For reference, initial attempt to bump LLVM from 15 to 16 is at #69654 (which focuses on updating libcxx, so unclear if JIT still works with patch). Latest LLVM stable release appears to be 19. Unknown if these resolve the AArch64 issue. |
|
I still don't see any link to llvm issue, so assuming an update to LLVM fixes anything is a long stretch. It might be a problem in our code |
|
@taiyang-li could you pls update this branch. i cannot push into it. loongarch build should be fixed then. |
|
LLVM JIT has a long track record of bugs; it is generally not safe. I'd bet (but not much) that it could be fixed in the recent versions. |
|
@nickitat I didn't mean to urge, just curious when can this PR ready to be merged? |
i meant it was already fixed in master by Alexey. this commit is not needed. pls remove it |
aa11786 to
7a74f02
Compare
done. |
* [GLUTEN-1632][CH]Daily Update Clickhouse Version (20241129) * Fix Build AND UT Due to [Added cache for primary index](ClickHouse/ClickHouse#72102) * Fix Build and UT due to [no auto write buffer finalization in destructors](ClickHouse/ClickHouse#68800) - Make LocalPartitionWriter::evictPartitions called, e.g. set(GlutenConfig.COLUMNAR_CH_SHUFFLE_SPILL_THRESHOLD.key, (1024*1024).toString) * Fix Build due to [Save several minutes of build time](ClickHouse/ClickHouse#72046) * Fix Benchmark Build due to [Scatter blocks in hash join without copying](ClickHouse/ClickHouse#67782) (cherry picked from commit 8d566d6a8b8785e4072ffd6f774eb83b07ac3d8d) * Fix Benchmark Build * Fix endless loop due to ClickHouse/ClickHouse#70598 * [Refactor #8100] using CHConf.setCHConfig() * fix style --------- Co-authored-by: kyligence-git <[email protected]> Co-authored-by: Chang Chen <[email protected]>
|
Crashes have been found: #72936 SELECT 1023, (((id % -9223372036854775807) = NULL) OR ((id % NULL) = 100)) = ((id % inf) = toUInt128(9223372036854775806)), (id % NULL) = NULL, (id % materialize(toNullable(3.4028234663852886e38))) |
|
@Algunenano I'll try to fix it. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Enable JIT compilation for more expressions: abs/bitCount/sign/modulo/pmod/isNull/isNotNull/assumeNotNull/to(U)Int*/toFloat*, comparison functions(=, <, >, >=, <=), logical functions(and, or).
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):