Skip to content

fine grained shuffle occupy too much memory when max_threads is large #10337

@guo-shaoge

Description

@guo-shaoge

Enhancement

On the dev machine (72C), When running the following query, memory usage is 12G+, but when change max_threads to 8, the memory usage is smaller.

Image

Most memory is occupied by FineGrainedShuffleWriter, we need to optimize the memory usage

Image

Env is as follow:

query: explain analyze select * from (select *, row_number() over (partition by ps_partkey order by ps_partkey) as rn from partsupp) d where rn = 1;
workload: tpch-50G
cluster: 1 tidb, 3 tikv, 3 tiflash, 1 pd
version:

mysql> select tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                             |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v9.0.0-beta.2.pre-275-g3409448
Edition: Community
Git Commit Hash: 3409448d3b9c405df37755f047c28bb0195ee891
Git Branch: HEAD
UTC Build Time: 2025-08-06 05:59:46
GoVersion: go1.23.11
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Kernel Type: Classic |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.component/computeseverity/majortype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions