pingcap / pingcap/tidb

executor: track dynamic deque memory in sliding Window aggregate functions

Open
#70,643 0 comments 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

The Window executor does not fully track the dynamic memory used by deque-backed sliding aggregate functions.

During sliding-window evaluation, `MIN`/`MAX` use `MinMaxDeque`, while `MIN_COUNT`/`MAX_COUNT` use `minMaxCountDeque` (including nested index slices). Their internal slices can grow with the window frame, but the current memory accounting only covers fixed partial-result sizes. In addition, `Reset` retains the backing-array capacity.

As a result, Window operator memory shown in execution profiles can be underestimated, and `tidb_mem_quota_query` may not detect and terminate memory-intensive Window queries in time, increasing OOM risk.

Track dynamic deque and nested-slice capacity changes consistently throughout the Window aggregate lifecycle.

Contributor guide

Open the contributing guide

Research direction

Start by locating the Window executor and the MinMaxDeque and minMaxCountDeque implementations, then inspect their memory accounting and Reset paths. Trace capacity changes during sliding-window evaluation, including nested index slices; done means dynamic deque memory is consistently accounted for throughout the aggregate lifecycle and profiles reflect it.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.