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

Increased latency over time in V49 #354

Closed
Andrews54757 opened this issue Nov 7, 2024 · 7 comments
Closed

Increased latency over time in V49 #354

Andrews54757 opened this issue Nov 7, 2024 · 7 comments
Labels
bug Something isn't working next release This Feature will go out with the next release

Comments

@Andrews54757
Copy link

Since updating the app (via play store) to V49, I've noticed an increased latency when visiting websites, manifesting as long loading times. This latency appears to grow with time and usage, only resolving by restarting the app. I've since downgraded to V47 and I have not seen this issue again.

Thanks for the amazing app!

Device information

Galaxy S10, android v12.

TetherFI configuration

5Ghz direct wifi connection, with always alive on and max performance power balance settings. unrestricted power management.

@pyamsoft pyamsoft added the bug Something isn't working label Nov 7, 2024
@pyamsoft
Copy link
Owner

pyamsoft commented Nov 7, 2024

Interesting, while the structure of the code has changed the underlying logic is relatively untouched.

If latency gets worse as you browse longer, I wonder if this is due to bigger and bigger copy actions from the data and bandwidth tracker.

I may have to remove the feature for now if it is affecting speeds

@pyamsoft
Copy link
Owner

pyamsoft commented Nov 7, 2024

About how long does it take to occur, and what websites are you browsing generally when you notice?

@Andrews54757
Copy link
Author

It tends to occur within 10 minutes of browsing. affects websites from google to youtube.

@pyamsoft
Copy link
Owner

pyamsoft commented Nov 7, 2024

Thank you

Let me set up some tests to see if I can reproduce the problem

@pyamsoft
Copy link
Owner

pyamsoft commented Nov 8, 2024

I've confirmed some kind of performance regression from 47 to 49, but it's deep in there - it will be a little tricky. I do not have a good chunk of time this week to sit down, but I suspect it has to do with client handling.

Assuming I can fix this, I will build more tests that ensure performance stays snappy for future versions, thanks :)

@pyamsoft
Copy link
Owner

pyamsoft commented Nov 8, 2024

Hello

I've noticed a few things regarding the new version 49 (warning: LONG)

  1. TetherFi is powered by a nice Kotlin library called KTOR made by a company called Jetbrains. KTOR used to be at version 2.X, which we were using internally. This library made internet "connect" calls that took, lets say, around 100ms on a test machine. TetherFi from version 49 onward uses KTOR version 3 which just released, and this version appears to connect every so slightly slower, at 150ms.

  2. TetherFi version 49 deprecated the power balance setting, which differs from the old version in one significant way. The absolute fastest performance was on unrestricted balance mode, but changes in 49 deprecated this mode and removed it from the codebase. This change was made without me knowing all of the facts, and I believe this is a cause of significant slowdown. To keep a complex topic simple, after you device makes "enough" connections, where "enough" is determined by the "number of CPU cores you have", the connection speed will begin to slow down as internal we are fighting for resources.

  3. This fight for resources was compounded by the fact that TetherFi used to never close socket connections, which meant that old "dead" Internet connections just sat around doing nothing and making things slow. Version 49 changed this to enforce a "dead connection cleanup" every 1 minute but this timeout period was obviously too slow. Version 50 will reduce this time down to 10 seconds.

Given these three changes, I wrote a simple shell script called stresstest that lives in the /bin folder in this repository, where I make 100 curl requests to example.com and time each one.
Before making these adjustments, 100 requests would take around 40 seconds on a Galaxy S24 - after making this change with unrestricted mode it takes around 10 seconds (depending on your internet speed)

I believe these changes will significantly improve the experience for you. Version 50 will be entering the store Beta hopefully sometime tonight or tomorrow and I will release it live once testing is completed.

Thank you for your patience and your contribution to the project

@pyamsoft pyamsoft added the next release This Feature will go out with the next release label Nov 8, 2024
@pyamsoft
Copy link
Owner

pyamsoft commented Nov 9, 2024

Version 51 is in production testing in the store and will become public later this week (assuming Google likes it)

Please double check your power balance settings in 51, as the options may have changed.

Thank you!

@pyamsoft pyamsoft closed this as completed Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next release This Feature will go out with the next release
Projects
None yet
Development

No branches or pull requests

2 participants