Skip to content

Commit 00f4bd2

Browse files
authored
fix(query): increase state_rows in copy agg state rows (#17252)
* fix(query): increase state_rows in copy agg state rows * fix(query): increase state_rows in copy agg state rows * fix(query): increase state_rows in copy agg state rows
1 parent 4fa72b1 commit 00f4bd2

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

src/query/expression/src/aggregate/payload.rs

+1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ impl Payload {
350350
)
351351
}
352352
page.rows += 1;
353+
page.state_rows += 1;
353354

354355
if page.rows == page.capacity {
355356
(page, _) = self.writable_page();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
executing 1
2+
executing 2
3+
executing 3
4+
executing 4
5+
executing 5
6+
Memory usage difference is less than 5%
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
3+
. "$CURDIR"/../../../shell_env.sh
4+
5+
6+
## warmup
7+
for i in `seq 1 2`;do
8+
$BENDSQL_CLIENT_CONNECT --query="""
9+
select number::string , max(number::string), min(number::string), count(distinct number) from numbers(10000000) group by 1 ignore_result;
10+
"""
11+
done
12+
13+
14+
PIDS=($(pgrep databend-query))
15+
BEFORE_MEM=0
16+
for PID in "${PIDS[@]}"; do
17+
MEM=$(ps -o rss= -p $PID | tail -n 1)
18+
BEFORE_MEM=$((BEFORE_MEM + MEM))
19+
done
20+
21+
22+
for i in `seq 1 5`;do
23+
echo "executing $i"
24+
$BENDSQL_CLIENT_CONNECT --query="""
25+
select number::string , max(number::string), min(number::string), count(distinct number) from numbers(10000000) group by 1 ignore_result;
26+
"""
27+
done
28+
29+
sleep 15
30+
31+
32+
AFTER_MEM=0
33+
for PID in "${PIDS[@]}"; do
34+
MEM=$(ps -o rss= -p $PID | tail -n 1)
35+
AFTER_MEM=$((AFTER_MEM + MEM))
36+
done
37+
38+
# Calculate the difference in percentage
39+
DIFF=$(awk -v before=$BEFORE_MEM -v after=$AFTER_MEM 'BEGIN {print (after-before)/before * 100}')
40+
41+
# Check if the difference is less than 5%
42+
if (( $(awk -v diff=$DIFF 'BEGIN {print (diff < 5)}') )); then
43+
echo "Memory usage difference is less than 5%"
44+
else
45+
echo "Memory usage difference is greater than 5%, before ${BEFORE_MEM} ${AFTER_MEM}"
46+
fi

0 commit comments

Comments
 (0)