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

Experimental: uses ktor to perform HTTP calls #935

Draft
wants to merge 3 commits into
base: release/1.21.0
Choose a base branch
from

Conversation

SessionHero01
Copy link
Collaborator

@SessionHero01 SessionHero01 commented Feb 11, 2025

This is an experimental PR that tries to replace okhttp with ktor as our main http library.

This is due to the thread model used in okhttp isn't scalable: it's a blocking thread based model. This means that if you happen to have 100 groups you'll likely end up with 100 threads while they are all polling at the same time. If you limit the thread number, all threads will be blocked busy waiting for the http polling and leave no rooms for other operations.

In contrast, ktor/cio uses a selector model which can scale up network concurrency almost limitedlessly(* still subjects to system resources but no threads are created as the number of connection increases).

This PR is here so that people can try out if it makes any significant performance improvement, particularly when you have large number of groups (for a small number of groups it's expected to not have any advantage).

TODO list:

  • Certificate pinning not working
  • Rewrite the inflexible implemention of ProfileCipherInputStream where it assumes things about a particular cipher. This "particular cipher" has to be removed so that ktor/tls works.
  • Replace other usages of okhttp
  • Remove okhttp altogether

@SessionHero01 SessionHero01 marked this pull request as draft February 11, 2025 23:42
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

Successfully merging this pull request may close these issues.

1 participant