Skip to content

GCC: RateController does not use the internal state #271

@N1cOs

Description

@N1cOs

Your environment.

  • Version: v0.1.30

What did you do?

RateController on the delay stats update doesn't use the internals state. Should we make a transition from the internal state, not from the current one (which is always increase actually)? Snippet from the rate_controller.go :

func (c *rateController) onDelayStats(ds DelayStats) {
	now := time.Now()

	if !c.init {
		c.delayStats = ds
		c.delayStats.State = stateIncrease
		c.init = true
		return
	}
	c.delayStats = ds
	// Transition from the current state?
	c.delayStats.State = c.delayStats.State.transition(ds.Usage)

	if c.delayStats.State == stateHold {
		return
	}

	// ... more logic
}

What did you expect?

Using the internal state (smth like this):

func (c *rateController) onDelayStats(ds DelayStats) {
	now := time.Now()

	if !c.init {
		c.delayStats = ds
		c.delayStats.State = stateIncrease
		c.init = true
		return
	}
	
	prev := c.delayStats
	c.delayStats = ds
	c.delayStats.State = prev.State.transition(ds.Usage)

	if c.delayStats.State == stateHold {
		return
	}

	// ... more logic
}

What happened?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions