168-reduce-circwindow.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. Filename: 168-reduce-circwindow.txt
  2. Title: Reduce default circuit window
  3. Author: Roger Dingledine
  4. Created: 12-Aug-2009
  5. Status: Open
  6. Target: 0.2.2
  7. 0. History
  8. 1. Overview
  9. We should reduce the starting circuit "package window" from 1000 to
  10. 101. The lower package window will mean that clients will only be able
  11. to receive 101 cells (~50KB) on a circuit before they need to send a
  12. 'sendme' acknowledgement cell to request 100 more.
  13. Starting with a lower package window on exit relays should save on
  14. buffer sizes (and thus memory requirements for the exit relay), and
  15. should save on queue sizes (and thus latency for users).
  16. Lowering the package window will induce an extra round-trip for every
  17. additional 50298 bytes of the circuit. This extra step is clearly a
  18. slow-down for large streams, but ultimately we hope that a) clients
  19. fetching smaller streams will see better response, and b) slowing
  20. down the large streams in this way will produce lower e2e latencies,
  21. so the round-trips won't be so bad.
  22. 2. Motivation
  23. Karsten's torperf graphs show that the median download time for a 50KB
  24. file over Tor in mid 2009 is 7.7 seconds, whereas the median download
  25. time for 1MB and 5MB are around 50s and 150s respectively. The 7.7
  26. second figure is way too high, whereas the 50s and 150s figures are
  27. surprisingly low.
  28. The median round-trip latency appears to be around 2s, with 25% of
  29. the data points taking more than 5s. That's a lot of variance.
  30. We designed Tor originally with the original goal of maximizing
  31. throughput. We figured that would also optimize other network properties
  32. like round-trip latency. Looks like we were wrong.
  33. 3. Design
  34. Wherever we initialize the circuit package window, initialize it to
  35. 101 rather than 1000. Reducing it should be safe even when interacting
  36. with old Tors: the old Tors will receive the 101 cells and send back
  37. a sendme ack cell. They'll still have much higher deliver windows,
  38. but the rest of their deliver window will go unused.
  39. You can find the patch at arma/circwindow. It seems to work.
  40. 3.1. Why not 100?
  41. Tor 0.0.0 through 0.2.1.19 have a bug where they only send the sendme
  42. ack cell after 101 cells rather than the intended 100 cells.
  43. Once 0.2.1.19 is obsolete we can change it back to 100 if we like. But
  44. hopefully we'll have moved to some datagram protocol long before
  45. 0.2.1.19 becomes obsolete.
  46. 3.2. What about stream packaging windows?
  47. Right now the stream packaging windows start at 500. The goal was to
  48. set the stream window to half the circuit window, to provide a crude
  49. load balancing between streams on the same circuit. Once we lower
  50. the circuit packaging window, the stream packaging window basically
  51. becomes redundant.
  52. We could leave it in -- it isn't hurting much in either case. Or we
  53. could take it out -- people building other Tor clients would thank us
  54. for that step. Alas, people building other Tor clients are going to
  55. have to be compatible with current Tor clients, so in practice there's
  56. no point taking out the stream packaging windows.
  57. 3.3. What about variable circuit windows?
  58. Once upon a time we imagined adapting the circuit package window to
  59. the network conditions. That is, we would start the window small,
  60. and raise it based on the latency and throughput we see.
  61. In theory that crude imitation of TCP's windowing system would allow
  62. us to adapt to fill the network better. In practice, I think we want
  63. to stick with the small window and never raise it. The low cap reduces
  64. the total throughput you can get from Tor for a given circuit. But
  65. that's a feature, not a bug.
  66. 4. Evaluation
  67. How do we know this change is actually smart? It seems intuitive that
  68. it's helpful, and some smart systems people have agreed that it's
  69. a good idea (or said another way, they were shocked at how big the
  70. default package window was before).
  71. To get a more concrete sense of the benefit, though, Karsten has been
  72. running torperf side-by-side on exit relays with the old package window
  73. vs the new one. The results are mixed currently -- it is slightly faster
  74. for fetching 40KB files, and slightly slower for fetching 50KB files.
  75. I think it's going to be tough to get a clear conclusion that this is
  76. a good design just by comparing one exit relay running the patch. The
  77. trouble is that the other hops in the circuits are still getting bogged
  78. down by other clients introducing too much traffic into the network.
  79. Ultimately, we'll want to put the circwindow parameter into the
  80. consensus so we can test a broader range of values once enough relays
  81. have upgraded.
  82. 5. Transition and deployment
  83. We should put the circwindow in the consensus (see proposal 167),
  84. with an initial value of 101. Then as more exit relays upgrade,
  85. clients should seamlessly get the better behavior.
  86. Note that upgrading the exit relay will only affect the "download"
  87. package window. An old client that's uploading lots of bytes will
  88. continue to use the old package window at the client side, and we
  89. can't throttle that window at the exit side without breaking protocol.
  90. The real question then is what we should backport to 0.2.1. Assuming
  91. this could be a big performance win, we can't afford to wait until
  92. 0.2.2.x comes out before starting to see the changes here. So we have
  93. two options as I see them:
  94. a) once clients in 0.2.2.x know how to read the value out of the
  95. consensus, and it's been tested for a bit, backport that part to
  96. 0.2.1.x.
  97. b) if it's too complex to backport, just pick a number, like 101, and
  98. backport that number.
  99. Clearly choice (a) is the better one if the consensus parsing part
  100. isn't very complex. Let's shoot for that, and fall back to (b) if the
  101. patch turns out to be so big that we reconsider.