Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

relay_buffer_results.txt 9.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. Date: 2026-03-27
  2. Platform: darwin/arm64, Apple M4, 10 cores
  3. Go version: see go version output
  4. Test: relay buffer size impact on syscalls and throughput
  5. === TEST A: client→telegram (through TLS layer) ===
  6. Buffer reads from tls.Conn.Read() → readBuf (bytes.Buffer, memcpy).
  7. BenchmarkClientToTelegram_TLSRead/buf=4096-10 861 1405852 ns/op 7458.65 MB/s 322.0 underlying_reads 122929 B/op 1309 allocs/op
  8. BenchmarkClientToTelegram_TLSRead/buf=4096-10 853 1401737 ns/op 7480.55 MB/s 322.0 underlying_reads 122916 B/op 1309 allocs/op
  9. BenchmarkClientToTelegram_TLSRead/buf=4096-10 907 1361807 ns/op 7699.89 MB/s 322.0 underlying_reads 122919 B/op 1309 allocs/op
  10. BenchmarkClientToTelegram_TLSRead/buf=8192-10 855 1402162 ns/op 7478.28 MB/s 322.0 underlying_reads 127009 B/op 1309 allocs/op
  11. BenchmarkClientToTelegram_TLSRead/buf=8192-10 850 1416311 ns/op 7403.57 MB/s 322.0 underlying_reads 127011 B/op 1309 allocs/op
  12. BenchmarkClientToTelegram_TLSRead/buf=8192-10 850 1403007 ns/op 7473.78 MB/s 322.0 underlying_reads 127014 B/op 1309 allocs/op
  13. BenchmarkClientToTelegram_TLSRead/buf=16379-10 867 1393915 ns/op 7522.52 MB/s 322.0 underlying_reads 135204 B/op 1309 allocs/op
  14. BenchmarkClientToTelegram_TLSRead/buf=16379-10 859 1403641 ns/op 7470.40 MB/s 322.0 underlying_reads 135201 B/op 1309 allocs/op
  15. BenchmarkClientToTelegram_TLSRead/buf=16379-10 855 1390302 ns/op 7542.07 MB/s 322.0 underlying_reads 135198 B/op 1309 allocs/op
  16. === TEST B: telegram→client (raw TCP, no TLS) ===
  17. Buffer directly determines read(2) size on raw connection.
  18. BenchmarkTelegramToClient_RawRead/buf=4096-10 219 5389256 ns/op 1945.68 MB/s 1281 underlying_reads 10500512 B/op 28 allocs/op
  19. BenchmarkTelegramToClient_RawRead/buf=4096-10 222 5377725 ns/op 1949.85 MB/s 1281 underlying_reads 10501322 B/op 28 allocs/op
  20. BenchmarkTelegramToClient_RawRead/buf=4096-10 222 5376614 ns/op 1950.25 MB/s 1281 underlying_reads 10497520 B/op 26 allocs/op
  21. BenchmarkTelegramToClient_RawRead/buf=8192-10 223 5389741 ns/op 1945.50 MB/s 1281 underlying_reads 10501422 B/op 26 allocs/op
  22. BenchmarkTelegramToClient_RawRead/buf=8192-10 223 5400624 ns/op 1941.58 MB/s 1281 underlying_reads 10501379 B/op 26 allocs/op
  23. BenchmarkTelegramToClient_RawRead/buf=8192-10 222 5396905 ns/op 1942.92 MB/s 1281 underlying_reads 10501594 B/op 26 allocs/op
  24. BenchmarkTelegramToClient_RawRead/buf=16379-10 223 5395730 ns/op 1943.34 MB/s 1281 underlying_reads 10509503 B/op 26 allocs/op
  25. BenchmarkTelegramToClient_RawRead/buf=16379-10 220 5382701 ns/op 1948.05 MB/s 1281 underlying_reads 10509719 B/op 26 allocs/op
  26. BenchmarkTelegramToClient_RawRead/buf=16379-10 220 5417737 ns/op 1935.45 MB/s 1281 underlying_reads 10509734 B/op 26 allocs/op
  27. === TEST C: Media download (burst) ===
  28. BenchmarkMediaDownload_Burst/buf=4096-10 1390 871425 ns/op 12032.89 MB/s 1281 underlying_reads 5573 B/op 16 allocs/op
  29. BenchmarkMediaDownload_Burst/buf=4096-10 1448 829255 ns/op 12644.79 MB/s 1281 underlying_reads 5572 B/op 16 allocs/op
  30. BenchmarkMediaDownload_Burst/buf=4096-10 1448 827359 ns/op 12673.78 MB/s 1281 underlying_reads 5568 B/op 16 allocs/op
  31. BenchmarkMediaDownload_Burst/buf=8192-10 1443 827113 ns/op 12677.54 MB/s 1281 underlying_reads 9666 B/op 16 allocs/op
  32. BenchmarkMediaDownload_Burst/buf=8192-10 1447 823708 ns/op 12729.94 MB/s 1281 underlying_reads 9667 B/op 16 allocs/op
  33. BenchmarkMediaDownload_Burst/buf=8192-10 1455 827683 ns/op 12668.80 MB/s 1281 underlying_reads 9666 B/op 16 allocs/op
  34. BenchmarkMediaDownload_Burst/buf=16379-10 1448 822379 ns/op 12750.52 MB/s 1281 underlying_reads 17858 B/op 16 allocs/op
  35. BenchmarkMediaDownload_Burst/buf=16379-10 1430 827035 ns/op 12678.74 MB/s 1281 underlying_reads 17858 B/op 16 allocs/op
  36. BenchmarkMediaDownload_Burst/buf=16379-10 1370 824312 ns/op 12720.62 MB/s 1281 underlying_reads 17857 B/op 16 allocs/op
  37. === TEST C: Media download (MTU-sized chunks ~1460 bytes) ===
  38. BenchmarkMediaDownload_MTU/buf=4096-10 319 3723040 ns/op 2816.45 MB/s 7184 underlying_reads 7128 B/op 17 allocs/op
  39. BenchmarkMediaDownload_MTU/buf=4096-10 325 3682345 ns/op 2847.58 MB/s 7184 underlying_reads 7128 B/op 17 allocs/op
  40. BenchmarkMediaDownload_MTU/buf=4096-10 324 3695782 ns/op 2837.22 MB/s 7184 underlying_reads 7125 B/op 17 allocs/op
  41. BenchmarkMediaDownload_MTU/buf=8192-10 321 3691560 ns/op 2840.47 MB/s 7184 underlying_reads 11236 B/op 17 allocs/op
  42. BenchmarkMediaDownload_MTU/buf=8192-10 320 3689589 ns/op 2841.99 MB/s 7184 underlying_reads 11229 B/op 17 allocs/op
  43. BenchmarkMediaDownload_MTU/buf=8192-10 322 3706004 ns/op 2829.40 MB/s 7184 underlying_reads 11233 B/op 17 allocs/op
  44. BenchmarkMediaDownload_MTU/buf=16379-10 321 3700978 ns/op 2833.24 MB/s 7184 underlying_reads 19419 B/op 17 allocs/op
  45. BenchmarkMediaDownload_MTU/buf=16379-10 324 3683697 ns/op 2846.53 MB/s 7184 underlying_reads 19438 B/op 17 allocs/op
  46. BenchmarkMediaDownload_MTU/buf=16379-10 326 3671021 ns/op 2856.36 MB/s 7184 underlying_reads 19399 B/op 17 allocs/op
  47. === TEST C: Media upload (through TLS) ===
  48. BenchmarkMediaUpload_TLS/buf=4096-10 876 1373218 ns/op 7635.91 MB/s 322.0 underlying_reads 122915 B/op 1309 allocs/op
  49. BenchmarkMediaUpload_TLS/buf=4096-10 871 1371760 ns/op 7644.02 MB/s 322.0 underlying_reads 122913 B/op 1309 allocs/op
  50. BenchmarkMediaUpload_TLS/buf=4096-10 882 1374420 ns/op 7629.22 MB/s 322.0 underlying_reads 122916 B/op 1309 allocs/op
  51. BenchmarkMediaUpload_TLS/buf=8192-10 865 1371958 ns/op 7642.92 MB/s 322.0 underlying_reads 127009 B/op 1309 allocs/op
  52. BenchmarkMediaUpload_TLS/buf=8192-10 871 1367871 ns/op 7665.75 MB/s 322.0 underlying_reads 127010 B/op 1309 allocs/op
  53. BenchmarkMediaUpload_TLS/buf=8192-10 873 1367689 ns/op 7666.77 MB/s 322.0 underlying_reads 127015 B/op 1309 allocs/op
  54. BenchmarkMediaUpload_TLS/buf=16379-10 879 1359754 ns/op 7711.51 MB/s 322.0 underlying_reads 135198 B/op 1309 allocs/op
  55. BenchmarkMediaUpload_TLS/buf=16379-10 865 1364028 ns/op 7687.35 MB/s 322.0 underlying_reads 135198 B/op 1309 allocs/op
  56. BenchmarkMediaUpload_TLS/buf=16379-10 961 1340296 ns/op 7823.47 MB/s 322.0 underlying_reads 135201 B/op 1309 allocs/op
  57. === TEST D: Small messages - telegram→client ===
  58. BenchmarkSmallMessages_TelegramToClient/buf=4096-10 232 5104819 ns/op 391.79 MB/s 10001 underlying_reads 5797 B/op 17 allocs/op
  59. BenchmarkSmallMessages_TelegramToClient/buf=4096-10 235 5082601 ns/op 393.50 MB/s 10001 underlying_reads 5842 B/op 17 allocs/op
  60. BenchmarkSmallMessages_TelegramToClient/buf=4096-10 238 5055601 ns/op 395.60 MB/s 10001 underlying_reads 5820 B/op 17 allocs/op
  61. BenchmarkSmallMessages_TelegramToClient/buf=8192-10 236 5044614 ns/op 396.46 MB/s 10001 underlying_reads 9917 B/op 17 allocs/op
  62. BenchmarkSmallMessages_TelegramToClient/buf=8192-10 236 5095263 ns/op 392.52 MB/s 10001 underlying_reads 9918 B/op 17 allocs/op
  63. BenchmarkSmallMessages_TelegramToClient/buf=8192-10 242 4991226 ns/op 400.70 MB/s 10001 underlying_reads 9924 B/op 17 allocs/op
  64. BenchmarkSmallMessages_TelegramToClient/buf=16379-10 242 4996066 ns/op 400.31 MB/s 10001 underlying_reads 18111 B/op 17 allocs/op
  65. BenchmarkSmallMessages_TelegramToClient/buf=16379-10 237 4976918 ns/op 401.86 MB/s 10001 underlying_reads 18121 B/op 17 allocs/op
  66. BenchmarkSmallMessages_TelegramToClient/buf=16379-10 241 4970618 ns/op 402.36 MB/s 10001 underlying_reads 18103 B/op 17 allocs/op
  67. === TEST D: Small messages - client→telegram (TLS) ===
  68. BenchmarkSmallMessages_ClientToTelegram/buf=4096-10 1209 987819 ns/op 2024.66 MB/s 64.00 underlying_reads 340302 B/op 20024 allocs/op
  69. BenchmarkSmallMessages_ClientToTelegram/buf=4096-10 1225 987831 ns/op 2024.64 MB/s 64.00 underlying_reads 340296 B/op 20024 allocs/op
  70. BenchmarkSmallMessages_ClientToTelegram/buf=4096-10 1208 988322 ns/op 2023.63 MB/s 64.00 underlying_reads 340311 B/op 20024 allocs/op
  71. BenchmarkSmallMessages_ClientToTelegram/buf=8192-10 1210 987411 ns/op 2025.50 MB/s 64.00 underlying_reads 344393 B/op 20024 allocs/op
  72. BenchmarkSmallMessages_ClientToTelegram/buf=8192-10 1209 987725 ns/op 2024.86 MB/s 64.00 underlying_reads 344394 B/op 20024 allocs/op
  73. BenchmarkSmallMessages_ClientToTelegram/buf=8192-10 1214 989274 ns/op 2021.68 MB/s 64.00 underlying_reads 344400 B/op 20024 allocs/op
  74. BenchmarkSmallMessages_ClientToTelegram/buf=16379-10 1203 986219 ns/op 2027.95 MB/s 64.00 underlying_reads 352581 B/op 20024 allocs/op
  75. BenchmarkSmallMessages_ClientToTelegram/buf=16379-10 1212 993873 ns/op 2012.33 MB/s 64.00 underlying_reads 352589 B/op 20024 allocs/op
  76. BenchmarkSmallMessages_ClientToTelegram/buf=16379-10 1203 991973 ns/op 2016.18 MB/s 64.00 underlying_reads 352593 B/op 20024 allocs/op