Skip to content

Commit

Permalink
scheduler: reduce deviceShare memory overhead
Browse files Browse the repository at this point in the history
Signed-off-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
  • Loading branch information
wangjianyu.wjy committed Jul 4, 2024
1 parent 0db9ea2 commit 11ee167
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/scheduler/plugins/deviceshare/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ func (p *Plugin) FilterReservation(ctx context.Context, cycleState *framework.Cy
}

func (p *Plugin) Reserve(ctx context.Context, cycleState *framework.CycleState, pod *corev1.Pod, nodeName string) *framework.Status {
defer func() {
// ReservationRestoreState is O(n) complexity of node number of the cluster.
// cleanReservationRestoreState clears ReservationRestoreState in the stateData to reduce memory cost before entering
// the binding cycle.
cleanReservationRestoreState(cycleState)
}()
state, status := getPreFilterState(cycleState)
if !status.IsSuccess() {
return status
Expand Down
4 changes: 4 additions & 0 deletions pkg/scheduler/plugins/deviceshare/reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func getReservationRestoreState(cycleState *framework.CycleState) *reservationRe
return state
}

func cleanReservationRestoreState(cycleState *framework.CycleState) {
cycleState.Delete(reservationRestoreStateKey)
}

func (s *reservationRestoreStateData) Clone() framework.StateData {
return s
}
Expand Down

0 comments on commit 11ee167

Please sign in to comment.