Skip to content
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 MySQL compression level variable and change default to compression level 3 #4764

Open
wants to merge 8 commits into
base: v3.0
Choose a base branch
from
24 changes: 20 additions & 4 deletions test/tap/tests/mysql-protocol_compression_level-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,20 @@ int main(int argc, char** argv) {
unsigned long time_proxy_compressed = 0;
unsigned long diff = 0;
unsigned long time_mysql_compressed = 0;
unsigned long time_mysql_without_compressed = 0;
std::string compression_level = {""};
int32_t ret = 0;
MYSQL* proxysql = nullptr;
MYSQL* proxysql_compression = nullptr;
MYSQL* proxysql_admin = nullptr;
MYSQL* mysql_compression = nullptr;
MYSQL* mysql = nullptr;
int performance_diff = 0;

if(cl.getEnv())
return exit_status();

plan(8);
plan(7);

// ProxySQL connection without compression
proxysql = initilize_mysql_connection(cl.host, cl.username, cl.password, cl.port, false);
Expand All @@ -100,6 +102,12 @@ int main(int argc, char** argv) {
goto cleanup;
}

// MySQL connection without compression
mysql = initilize_mysql_connection(cl.host, cl.username, cl.password, cl.mysql_port, false);
if (!mysql) {
goto cleanup;
}

// ProxySQL admin connection
proxysql_admin = initilize_mysql_connection(cl.host, cl.admin_username, cl.admin_password, cl.admin_port, false);
if (!proxysql_admin) {
Expand Down Expand Up @@ -144,10 +152,16 @@ int main(int argc, char** argv) {
goto cleanup;
}

diff = time_proxy_compressed - time_mysql_compressed;
performance_diff = (diff * 100) / time_mysql_compressed;
time_mysql_without_compressed = calculate_query_execution_time(mysql, query);
yashwantsahu20 marked this conversation as resolved.
Show resolved Hide resolved
diag("Time taken for query with mysql without compression: %ld", time_mysql_without_compressed);
if (time_mysql_without_compressed == -1) {
goto cleanup;
}

diff = time_mysql_without_compressed - time_mysql_compressed;
performance_diff = (diff * 100) / time_mysql_without_compressed;

ok((performance_diff < 20), "proxysql with compression performed well compared to mysql with compression. Performance difference: %d percentage", performance_diff);
diag("Time difference for mysql, compression and without compression is: %d", performance_diff);

ret = get_variable_value(proxysql_admin, "mysql-protocol_compression_level", compression_level, true);
if (ret == EXIT_SUCCESS) {
Expand Down Expand Up @@ -232,6 +246,8 @@ int main(int argc, char** argv) {
mysql_close(proxysql_compression);
if (mysql_compression)
mysql_close(mysql_compression);
if (mysql)
mysql_close(mysql);
if (proxysql_admin)
mysql_close(proxysql_admin);

Expand Down