automatic throttle burst size, #24699 (#24784)

* automatic throttle burst size, #24699

* throttleEven used maxBurst=Int.MaxValue, which in practise resulted
  in no throttling at all at high rates
* The original problem that throttleEven tried to solve was that when
  the throttle rate (cost / per) was high the cost of scheduling
  dominated and became much lower than the given rate, if 0 or low
  maxBurst was given. Difficult for user to know what maxBurst to use.
* In fact, that was already the case for rates > 30/s.
* This is fixed by automatically adjusting the maxBurst for higher
  throttle rates in a new throttle overload that doesn't include
  maxBurst parameter
* Also skipped the mode parameter for that variant since Shaping is
  what almost always is what you want, and otherwise you can use
  the full signature with a good maxBurst
* Deprecated throttleEven, since it is the same. Also fixed the
  implementation of throttleEven to use the automatic burst size,
  since Int.MaxValue is not useful at all.
This commit is contained in:
Patrik Nordwall 2018-04-02 16:07:16 +02:00 committed by Christopher Batey
parent ee85d23a3e
commit 6f330ef69c
14 changed files with 692 additions and 364 deletions

View file

@ -62,7 +62,7 @@ class QuickStartDocSpec extends WordSpec with BeforeAndAfterAll with ScalaFuture
//#add-streams
factorials
.zipWith(Source(0 to 100))((num, idx) s"$idx! = $num")
.throttle(1, 1.second, 1, ThrottleMode.shaping)
.throttle(1, 1.second)
//#add-streams
.take(3)
//#add-streams