Skip to content

rate-limiting: test enhancement + refactoring #223

Merged
htuch merged 18 commits intoenvoyproxy:masterfrom
oschaaf:rate-limiter-refactoring
Dec 12, 2019
Merged

rate-limiting: test enhancement + refactoring #223
htuch merged 18 commits intoenvoyproxy:masterfrom
oschaaf:rate-limiter-refactoring

Conversation

@oschaaf
Copy link
Copy Markdown
Member

@oschaaf oschaaf commented Dec 6, 2019

Modulo an improved test for the batching rate limiter,
this pulls off some refactoring for upcoming new rate
limiters.

This has no functional changes, and is an intermediate step for draft PR #218,
which contains new rate limiters (linear & probabilistic ramping, first stab at a zipf distribution support).

Signed-off-by: Otto van der Schaaf oschaaf@we-amp.com

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
…te-limiter

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Modulo an improved test for the batching rate limiter,
this pulls off some refactoring for upcoming new rate
limiters.

Split out off from draft PR  envoyproxy#218

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@mum4k mum4k requested a review from dubious90 December 9, 2019 21:03
Copy link
Copy Markdown
Contributor

@dubious90 dubious90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good. Have a couple questions.

* Base for a rate limiter which wraps another rate limiter, and forwards
* some calls.
*/
class ForwardingRateLimiterImpl : public RateLimiter {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If RateLimiterBaseImpl is the base RateLimiter class that we're working with, should this rate limiter also extend from it? Would it make sense to add a comment explaining why it doesn't? If it's because RateLimiterBaseImpl is too specific to be pulled from here, I might suggest that BaseImpl is a counterintuitive name for it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see your point, but I have a hard time coming up with a better name; hopefully the comment
I added in 6d1e747 help

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that your added comment clarifies things nicely. Thank you


bool DelegatingRateLimiter::tryAcquireOne() {
bool DelegatingRateLimiterImpl::tryAcquireOne() {
const auto now = timeSource().monotonicTime();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a slight functional change here? I'm not 100% sure I understand how monotonicTime() works here, but because you're pulling this value before tryAcquireOne here, if tryAcquireOne were to ever have a delay for any reason (even if only in certain impls), what now is capturing here is not equivalent to what now was capturing before.

If you don't think this is a legitimate concern, I will completely defer to you on this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, catch; I backed this out.
The behavioral change is quite small but as the PR description promised to not introduce these type of changes, this shouldn't go in here - and probably there is no value in making the change at all.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@dubious90
Copy link
Copy Markdown
Contributor

LGTM, htuch to approve

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a small docs ask.
/wait

…ctoring

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@htuch htuch merged commit 48e3fe1 into envoyproxy:master Dec 12, 2019
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

Successfully merging this pull request may close these issues.

3 participants