how the value of 'thresholdPermits' is cacluated in the SmoothWarmingUp?

94 views
Skip to first unread message

张凯

unread,
Oct 10, 2018, 10:21:57 PM10/10/18
to guava-discuss
https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java#L226

shows the formula of the 'thresholdPermits'

i cannot understand why doing so, why not 0.2 * warmupPeriod/ stalbeInterval

thanks very much!

Dimitris Andreou

unread,
Oct 11, 2018, 10:05:46 AM10/11/18
to 张凯, guava-discuss
It's explained few lines above, L193 in particular. Basically, the code implements a mathematical function which consists of two lines. The two lines meet at a point ("thresholdPermits"). On the left of that point, the function is horizontal line, on the right, it's a sloped line (the sloped line corresponds to the warming up effect). The code you linked recomputes that meeting point, given that it depends on the rate.

--
guava-...@googlegroups.com
Project site: https://github.com/google/guava
This group: http://groups.google.com/group/guava-discuss
 
This list is for general discussion.
To report an issue: https://github.com/google/guava/issues/new
To get help: http://stackoverflow.com/questions/ask?tags=guava
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/65abb755-9efb-4c60-bc33-e7cf703fccce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

张凯

unread,
Oct 11, 2018, 10:59:22 PM10/11/18
to guava-discuss
OK, thank you


"The reason that this is warmupPeriod/2 is to maintain the behavior of the original implementation where coldFactor was hard coded as 3"

so the value of warmupPeriod/2 is empirical valued ?

and can i choose the time to go from thresholdPermits to 0 with another vaule, such as warmupPeriod/3

在 2018年10月11日星期四 UTC+8下午10:05:46,Dimitris Andreou写道:

Dimitris Andreou

unread,
Oct 12, 2018, 5:05:39 AM10/12/18
to 张凯, guava-discuss
It's an arbitrary value rather, not empirical. Most people who want a warmup behavior (and that's already very few people) don't care about the precise shape of the throughput during a warm-up or cool-down, so it doesn't make sense to offer an overcomplicated API that nobody would use.

This particular value controls the cool-down effect of a previously fully-utilized ratelimiter which is now unused. If this value was shorter (even 0), then the ratelimiter would immediately start to cool-down as soon as it is not fully utilized. That the value is >0 means that there's a buffer, a fully utilized ratelimiter doesn't start cooling down (thus throttling more, to warmup) just because there was a blip in incoming traffic.

张凯

unread,
Oct 12, 2018, 7:05:25 AM10/12/18
to guava-discuss
i got it, thank you ;)

在 2018年10月12日星期五 UTC+8下午5:05:39,Dimitris Andreou写道:
Reply all
Reply to author
Forward
0 new messages