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

Version 1.0.0 has less perfromance, than 0.9.5 #41

Closed
devbreath opened this issue Jul 7, 2018 · 21 comments
Closed

Version 1.0.0 has less perfromance, than 0.9.5 #41

devbreath opened this issue Jul 7, 2018 · 21 comments

Comments

@devbreath
Copy link

Hi,

After switching to version 1.0.0, I found, that clients may transfer data with less 250Kb/s. Version 0.9.5 executed on the same machine in separate docker provide 2,5Mb/s.
I changed size of buffer TO_CLT_BUFSIZE = 16384 via config.py and speed was improved to 510Kb/s (v1.0.0).
Both tests was done on the same physical machine, with different docker containers, the same secrets and the same clients(desktop and Android). If I switch to "secure" secret, I've also get less performance rate(v1.0.0).

Have you got any suggestions, why new version may be slower on the same secrets?

@GoldenOne1
Copy link

I have this problem too

@alexbers
Copy link
Owner

alexbers commented Jul 8, 2018

Hi,

There is a trade-off between memory consumption and performance. The more buffers you have, the more speed you are able to reach, but the more memory you need. The proxy can be launched on different hardware: on the machine with several hundreds GB of RAM, or on the small home router with hundreds MB of RAM. And the purpose of proxy can also be different: it can be for small company, or for large ones.

I am trying to specify the defaults to fit the requirements of most users. In the lattest version I increased its size back to 16384: c2ad0de. But if you need more speed, or have a lot of memory you can enlarge it even more until the speed will be satisfying.

Best,
Alexander Bersenev

@devbreath
Copy link
Author

devbreath commented Jul 8, 2018

Thank you for explanation!
I am wondered, that version 1.0.0 slower than version 0.9.5, like 510Kb/s vs 2,5Mb/s (~5 times difference), even with the same buffer size. I can't find any reason for this.

P.S. Buffer size for version 1.0.0 changed via config.py.

@alexbers
Copy link
Owner

alexbers commented Jul 8, 2018

I think is because I forgot to set buffer sizes in some case: 675d5a6#diff-e2b821dc5d96409f0102669d33aa8637R609. This caused the default OS limit was used, and it is a fairly big limit (about 400KBytes on my test OS).

@devbreath
Copy link
Author

Just for information, a few seconds ago, I made new docker image from your master branch. Upload my config.py from version 0.9.5 and add follow strings:
TO_CLT_BUFSIZE = 16384
CLIENT_KEEPALIVE = 30*60
Speed of master branch ~600Kb/s
Speed of version 0.9.5 ~ 3Mb/s

@alexbers
Copy link
Owner

alexbers commented Jul 8, 2018

Could you, please try to remove this string from the do_direct_handshake function:
set_bufsizes(writer_tgt.get_extra_info("socket"), TO_CLT_BUFSIZE, TO_TG_BUFSIZE)

and rerun the test

@devbreath
Copy link
Author

Thank you!

After this change, speed of master branch version increased to 2,6Mb/s - 3,06Mb/s

@GoldenOne1
Copy link

i increased buffer to 64000
and removed this string:

set_bufsizes(writer_tgt.get_extra_info("socket"), TO_CLT_BUFSIZE, TO_TG_BUFSIZE)

but still download speed is very low

Version 0.9.5 was very fast

@alexbers
Copy link
Owner

could you, please, retry with these two string in config.py:
TO_CLT_BUFSIZE = 655360
TO_TG_BUFSIZE = 655360

@GoldenOne1
Copy link

Still very slow

250 KB/S

@alexbers
Copy link
Owner

also to make sure that this is due buffers, could you comment out all set_bufsizes calls (there should be two of them)

@GoldenOne1
Copy link

commented two of them and tested

still slow speed

@alexbers
Copy link
Owner

then, it is likely no due buffering changes. What is the CPU load during downloading?

@GoldenOne1
Copy link

cpu is normal during download and upload , cpu 3~7 percent

@alexbers
Copy link
Owner

the only variant left is the speed became slower due to internet provider of the server. Are you sure that the speed is still ok with v0.9.5?

@GoldenOne1
Copy link

yes im sure (0.9.5)

my server port is ok , download speed is above 20MB/S
and my download speed from telegram.org is 18MB/S

@GoldenOne1
Copy link

And in version 1.0.0 i get this error:

error updating middle proxy list
error updating middle proxy list for ipv6
error updating middle proxy list secret , using old

version 0.9.5 i dont get any error

@alexbers
Copy link
Owner

the logic of getting middle proxy list wasn't changed between 1.0.0 and 0.9.5. May be the packets from 1.0.0 are blocked by windows firewall?

@GoldenOne1
Copy link

GoldenOne1 commented Jul 11, 2018

Yes exactly

I turned off firewall and i don't get error any more

Picture download speed become very fast and improved a lot

Video download speed is still very very low 250KB/S

Do you have any idea for video?

And how can i turn firewall on without proxy problem? I already opened my proxy port in firewall and i don't know which port telegram uses

@GoldenOne1
Copy link

@alexbers

@alexbers
Copy link
Owner

The video speed could be low because the video is downloaded from some far telegram datacenter. You can try to increase the buffer sizes even more or try to compose custom telegram servers list by modifying https://core.telegram.org/getProxyConfig, leaving only few fastest server from every group and assigning them to TG_MIDDLE_PROXIES_V4 variable and commenting out the TG_MIDDLE_PROXIES_V4 = v4_proxies line. Also you can try to use "proxy_for 4" servers from "proxy_for -4" ones

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

3 participants