New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add throttling to snaphost and restore operations #4891
Conversation
+1, tested this locally and it works great. |
} | ||
|
||
@Override | ||
public int read(byte[] b) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can just delegate to read(byte[],int,int)
left some minor comments otherwise LGTM |
public int read() throws IOException { | ||
int b = delegate.read(); | ||
if (b > 0) { | ||
listener.onPause(rateLimiter.pause(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant something like this:
long pause = rateLimiter.pause(1);
if (pause > 0) {
listerner.onPause(pause);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be inconsistent with RateLimitedFSDirectory.Listener I also think that onPause(0) might be useful in certain cases. However, it should be if (b >= 0) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well this one is entirely different. It's a buffered input that only calls that on a flush which is every 8kb or so. This one is called for every byte? and I disagree as well on the >= though it should only be called if really needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant b >= 0
in case of bytes, not nanoseconds. In practice, this method is never called anyway, since none of the current implementations of blob store are using it to copy indices to a repository and I really hope they never will (it will be really bad performance decision anyway) So, if you feel strongly about (theoretically) not calling pause for every byte, I will implement your solution.
LGTM |
Closes #4855