-
Notifications
You must be signed in to change notification settings - Fork 509
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
client: implement qos based on leakybucket algorithm #268
Conversation
recheck |
1 similar comment
recheck |
19953dd
to
c236667
Compare
recheck |
7 similar comments
recheck |
recheck |
recheck |
recheck |
recheck |
recheck |
recheck |
c236667
to
49f958d
Compare
recheck |
conf/mds.conf
Outdated
#### throttle options #### | ||
# | ||
# iops | ||
mds.throttle.iopsMin=1800 |
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.
Basis for the default value?
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.
refer to the configuration of similar products of Ali Cloud and Tencent Cloud.
also, these configurations exceed the parameters of cinder.
curve-ansible/server.ini
Outdated
@@ -40,6 +40,12 @@ topo_file_path=/etc/curve/topo.json | |||
target_leader_range=3 | |||
check_leader_range_times=100 | |||
check_leader_range_interval=10 | |||
throttle_iops_min=1800 |
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.
The default value can be set here: curve-ansible/roles/generate_config/templates/main.yml
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.
done
BPS_WRITE = 5; | ||
} | ||
|
||
message ThrottleParams { |
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.
Why is it not directly included ThrottleType
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.
done
src/client/client_common.h
Outdated
@@ -72,6 +72,32 @@ enum class FileStatus { | |||
BeingCloned, | |||
}; | |||
|
|||
struct ThrottleParams { | |||
uint64_t limit; |
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.
Note the meaning of these parameters:
limit, burst, burstLength
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.
done
src/client/throttle.h
Outdated
|
||
FileThrottleParams throttleParams_; | ||
uint64_t enabledThrottleFlag_; | ||
std::vector<std::pair<uint64_t, common::TokenBucketThrottle*>> throttles_; |
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.
why not shared_ptr?
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.
no need to use shared_ptr, because those TokenBucketThrottle's lifetime is simple
src/client/throttle.h
Outdated
void UpdateThrottleParams(const FileThrottleParams& params); | ||
|
||
private: | ||
void ApplyThrottleLimit(uint64_t flag, uint64_t limit, uint64_t burst, |
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.
Annotation
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.
done
src/common/throttle.h
Outdated
|
||
void Get(uint64_t tokens); | ||
bool Get(uint64_t tokens, google::protobuf::Closure* done); | ||
int SetLimit(uint64_t average, uint64_t burst, uint64_t burstLength); |
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.
Why the previous parameters is limit instead of average?
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.
Limit in the previous parameter represents a value, abut for a token bucket, it needs to have an average generation rate to reach this limit. So, name this parameter and member value as average.
return TokensFilled(currentTick_) - TokensFilled(currentTick_ - 1); | ||
} | ||
|
||
private: |
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.
Appropriate notes
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.
done
src/common/throttle.h
Outdated
~TokenBucketThrottle(); | ||
|
||
void Get(uint64_t tokens); | ||
bool Get(uint64_t tokens, google::protobuf::Closure* done); |
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.
When are the two get called?add notes please
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.
done
@@ -0,0 +1,122 @@ | |||
/* |
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.
src/client/throttle.h not tested?
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.
add some test cases
src/client/io_tracker.cpp
Outdated
void IOTracker::DoRead(MDSClient* mdsclient, const FInfo_t* fileInfo, | ||
Throttle* throttle) { | ||
if (throttle) { | ||
throttle->Get(true, length_); |
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.
Will blocking here cause a deadlock ?
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.
If tokens is not enough, this call will block until tokens is available. And, when close a file, in throttle's destructor it will let a blocked requests pass.
src/client/io_tracker.cpp
Outdated
@@ -184,6 +192,10 @@ void IOTracker::DoWrite(MDSClient* mdsclient, const FInfo_t* fileInfo) { | |||
break; | |||
} | |||
|
|||
if (throttle) { | |||
throttle->Get(false, length_); |
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.
Have you tested performance after throttle here?
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.
Tested.
For IOPS throttle, the Get operation can exceed 100,000 qps.
and if disable all throttle, the performance is basically unchanged
@@ -37,6 +39,18 @@ inline uint64_t MaxPowerTimesLessEqualValue(uint64_t value) { | |||
return pow; | |||
} | |||
|
|||
template <typename T, typename Compare> |
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.
Annotation
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.
Done
192dc9e
to
32d8cd5
Compare
src/common/throttle.h
Outdated
void Get(uint64_t tokens); | ||
|
||
/** | ||
* @brief Get tokens, return false if the available token is not enough, |
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.
return True if the available token is not enough ?
src/common/throttle.h
Outdated
* and when the requirment is met, it will call done->Run() | ||
* @return return true if got enough tokens, otherwise return false | ||
*/ | ||
bool Get(uint64_t tokens, google::protobuf::Closure* done); |
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.
If this function is only called in the class 'TokenBucketThrottle', it can be 'private'.
9d63087
to
5636d22
Compare
5636d22
to
c4efa39
Compare
What problem does this PR solve?
Issue Number: close #xxx
Problem Summary:
What is changed and how it works?
What's Changed:
How it Works:
Side effects(Breaking backward compatibility? Performance regression?):
Check List