lila-ws icon indicating copy to clipboard operation
lila-ws copied to clipboard

Not sure if frameLag calc is ideal

Open isaacl opened this issue 1 year ago • 2 comments

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

isaacl avatar Nov 22 '22 16:11 isaacl

(or something of this nature, potentially an even higher weight for low frameLag recordings)

isaacl avatar Nov 22 '22 16:11 isaacl

I'll do some digging and follow up w a PR

isaacl avatar Nov 22 '22 20:11 isaacl