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

Use Caffeine instead of GuavaCache #17684

Closed
terrymanu opened this issue May 16, 2022 · 4 comments · Fixed by #17712
Closed

Use Caffeine instead of GuavaCache #17684

terrymanu opened this issue May 16, 2022 · 4 comments · Fixed by #17712

Comments

@terrymanu
Copy link
Member

The guava cache usage is in SQLStatementCacheBuilder and ParseTreeCacheBuilder, please replace it as Caffeine, and test the performance.

@magestacks
Copy link
Member

@terrymanu Can you assign it to me?

@terrymanu
Copy link
Member Author

Great, hope the feature can be finished soon

@taojintianxia
Copy link
Contributor

Compare the performance of Caffeine and Guava Cache in ShardingSphere

I tested the performance of caffeine and guava cache through ShardingSphere-Proxy, and put the test result as following :

Test Environment

Proxy-Sharding 5.1.2-SNOPSHOT(Test PR-17712 commit before and after performance)
MySQL 5.7.26
Guava Cache 30.0-jre
Caffeine 2.9.2
Software Address Port
Proxy-Sharding 10.0.0.201 3307
MySQL-1 10.0.0.211 3306
MySQL-2 10.0.0.212 3306
MySQL-3 10.0.0.213 3306
MySQL-4 10.0.0.214 3306
MySQL-5 10.0.0.215 3306
Sysbench 10.0.0.200

using Sharding mode for proxy

Test Plan

use SysBench as the testing tool. 1 million records, testing for 5 minutes.

	$ sysbench oltp_read_only 
		--mysql-host=$host 
		--mysql-port=$port 
		--mysql-user=$user 
		--mysql-password=$password 
		--mysql-db=$db 
		--tables=1 
		--table-size=1000000 
		--report-interval=10 
		--time=300 
		--threads=100 
		--max-requests=0 
		--percentile=99 
		--mysql-ignore-errors="all" 
		--rand-type=uniform 
		--range_selects=off 
		--auto_inc=off prepare

test the oltp_point_select,oltp_read_write,oltp_write_only script like following :

	$ sysbench oltp_point_select 
		--mysql-host=$host
		--mysql-port=$port
		--mysql-user=$user
		--mysql-password=$password 
		--mysql-db=$db 
		--tables=10 
		--table-size=1000000 
		--report-interval=5  
		--time=300 
		--threads=100 
		--max-requests=0 
		--percentile=99  
		--mysql-ignore-errors="all" 
		--range_selects=off 
		--rand-type=uniform 
		--auto_inc=off run

Test Result

1.point_select

Threads Guava Cache(QPS) Caffeine(QPS)
64 104332.74 105176.71
128 154790.42 156147.71

2.read_write

Threads Guava Cache(TPS) Caffeine(TPS)
64 5235.67 5269.40
128 7916.64 8021.03

3.write_only

Threads Guava Cache(TPS) Caffeine(TPS)
64 14061.15 14054.77
128 21412.49 21501.28

as we can see, for the action contains "reading data" operation, the PR contains Caffeine will increase 1% performace to the Guava Cache.

image

@ben-manes
Copy link

Vitess uses a Go cache that borrows from Caffeine’s design. Their query cache benchmark might be of interest to you. It defended from pollution which LRU suffers from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants