Skip to content

Commit

Permalink
No throttle when throttle_max_bytes_per_second_to_client == 0
Browse files Browse the repository at this point in the history
If throttle_max_bytes_per_second_to_client == 0, disable throttling.
This matches the mysql convention of 0 == no limit. Change the default
to 0.
  • Loading branch information
carsonip committed Mar 15, 2019
1 parent c590dbc commit cfe1c7f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ void MySQL_Session::writeout() {
int tps = 10; // throttling per second , by default every 100ms
int total_written = 0;
unsigned long long last_sent_=0;
bool disable_throttle = mysql_thread___throttle_max_bytes_per_second_to_client == 0;
int mwpl = mysql_thread___throttle_max_bytes_per_second_to_client; // max writes per call
mwpl = mwpl/tps;
if (client_myds) client_myds->array2buffer_full();
Expand All @@ -492,7 +493,7 @@ void MySQL_Session::writeout() {
if (retbytes==QUEUE_T_DEFAULT_SIZE) { // optimization to solve memory bloat
runloop=true;
}
while (runloop && total_written < mwpl) {
while (runloop && (disable_throttle || total_written < mwpl)) {
runloop=false; // the default
client_myds->array2buffer_full();
struct pollfd fds;
Expand All @@ -514,7 +515,7 @@ void MySQL_Session::writeout() {
}

// flow control
if (total_written > 0) {
if (!disable_throttle && total_written > 0) {
if (total_written > mwpl) {
unsigned long long add_ = 1000000/tps + 1000000/tps*((unsigned long long)total_written - (unsigned long long)mwpl)/mwpl;
pause_until = thread->curtime + add_;
Expand Down
4 changes: 2 additions & 2 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ MySQL_Threads_Handler::MySQL_Threads_Handler() {
variables.query_digests_max_digest_length=2*1024;
variables.query_digests_max_query_length=65000; // legacy default
variables.wait_timeout=8*3600*1000;
variables.throttle_max_bytes_per_second_to_client=2147483647;
variables.throttle_max_bytes_per_second_to_client=0;
variables.throttle_ratio_server_to_client=0;
variables.max_connections=10*1000;
variables.max_stmts_per_connection=20;
Expand Down Expand Up @@ -1629,7 +1629,7 @@ bool MySQL_Threads_Handler::set_variable(char *name, char *value) { // this is t
#endif // IDLE_THREADS
if (!strcasecmp(name,"throttle_max_bytes_per_second_to_client")) {
int intv=atoi(value);
if (intv >= 1024 && intv <= 2147483647) {
if (intv >= 0 && intv <= 2147483647) {
variables.throttle_max_bytes_per_second_to_client=intv;
return true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/mysql_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ MDB_ASYNC_ST MySQL_Connection::handler(short event) {
if (
(processed_bytes > (unsigned int)mysql_thread___threshold_resultset_size*8)
||
( mysql_thread___throttle_ratio_server_to_client && (processed_bytes > (unsigned long long)mysql_thread___throttle_max_bytes_per_second_to_client/10*(unsigned long long)mysql_thread___throttle_ratio_server_to_client) )
( mysql_thread___throttle_ratio_server_to_client && mysql_thread___throttle_max_bytes_per_second_to_client && (processed_bytes > (unsigned long long)mysql_thread___throttle_max_bytes_per_second_to_client/10*(unsigned long long)mysql_thread___throttle_ratio_server_to_client) )
) {
next_event(ASYNC_USE_RESULT_CONT); // we temporarily pause
} else {
Expand Down

0 comments on commit cfe1c7f

Please sign in to comment.