risinglightdb / risinglight

An educational OLAP database system.
Apache License 2.0
1.61k stars 214 forks source link

fix: fix out-of-memory in tpch q21 #850

Closed wangrunji0408 closed 6 months ago

wangrunji0408 commented 6 months ago

Signed-off-by: Runji Wang wangrunji0408@163.com

In HashSemiJoinExecutor2, data chunk builder for each key was reserved with 1024 capacity. But they only have 4 rows on average in TPC-Q Q21. Therefore, more than 4*1020*2*1500000 = 12GB memory was wasted.

This PR fixes this bug by using DataChunkBuilder with dynamic capacity. This PR also replaces vectors by boxed slices in array, making sure that unused memory is released after build. Finally, it enables q21 in CI.

run-q21                 time:   [2.6544 s 2.6956 s 2.7059 s]
                        change: [-61.787% -61.416% -61.045%] (p = 0.05 < 0.05)