Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not sure if frameLag calc is ideal #395

Open
isaacl opened this issue Nov 22, 2022 · 2 comments
Open

Not sure if frameLag calc is ideal #395

isaacl opened this issue Nov 22, 2022 · 2 comments

Comments

@isaacl
Copy link
Member

isaacl commented Nov 22, 2022

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
Copy link
Member Author

isaacl commented Nov 22, 2022

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

@isaacl
Copy link
Member Author

isaacl commented Nov 22, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant