Skip to content

Commit

Permalink
increase the priority of cursor fetch spilling
Browse files Browse the repository at this point in the history
Signed-off-by: Yang Keao <[email protected]>
  • Loading branch information
YangKeao committed Jul 5, 2023
1 parent a701418 commit 3517e7a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/conn_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ func (cc *clientConn) executePreparedStmtAndWriteResult(ctx context.Context, stm
defer actionSpill.WaitForTest()
}
})
vars.MemTracker.FallbackOldAndSetNewAction(rowContainer.ActionSpill())
action := memory.NewActionWithPriority(rowContainer.ActionSpill(), memory.DefCursorFetchSpillPriority)
vars.MemTracker.FallbackOldAndSetNewAction(action)
}
defer func() {
if err != nil {
Expand Down
22 changes: 22 additions & 0 deletions util/memory/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ type ActionOnExceed interface {
IsFinished() bool
}

var _ ActionOnExceed = &actionWithPriority{}

type actionWithPriority struct {
ActionOnExceed
priority int64
}

// NewActionWithPriority wraps the action with a new priority
func NewActionWithPriority(action ActionOnExceed, priority int64) *actionWithPriority {
return &actionWithPriority{
action,
priority,
}
}

func (a *actionWithPriority) GetPriority() int64 {
return a.priority
}

// ActionInvoker indicates the invoker of the Action.
type ActionInvoker byte

Expand Down Expand Up @@ -94,6 +113,9 @@ const (
DefPanicPriority = iota
DefLogPriority
DefSpillPriority
// DefCursorFetchSpillPriority is higher than normal disk spill, because it can release much more memory in the future.
// And the performance impaction of it is less than other disk-spill action, because it's write-only in execution stage.
DefCursorFetchSpillPriority
DefRateLimitPriority
)

Expand Down

0 comments on commit 3517e7a

Please sign in to comment.