Skip to content

Not sure if frameLag calc is ideal #395

Description

@isaacl

frameLag is currently a weighted running avg from trusted pongs.

This is very reasonable but what happens if a user hits a massive spike? The weighted avg skyrockets and won't return for a while. This translates into the old quota gain behavior for multiple moves in a row.

Consider:

  • capping millis so it can't skyrocket the frameLag weighted avg
  • changing the formula to drop faster if recording values that are lower than the current weighted avg.

For example:

private val trustedSpikeRefreshFactor = 0.05f
private val trustedNormalRefreshFactor = 0.1f
private val maxMillis = 5000
...

.fold(millis) { prev => {
    val weight = if (millis < prev) trustedNormalRefreshFactor else trustedSpikeRefreshFactor
    val cappedMillis = millis atMost maxMillis
    (prev * (1 - weight) + cappedMillis * weight).toInt
}
}

@ornicar @niklasf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions