这个场景下没有热门数据一说* gaussian:
? 1 2 3 4 5 6 7 8 9 10 unsigned ``int rnd_func_gaussian(``void``) { ``int sum; ``unsigned ``int i; ``for``(i=0, sum=0; i < args.dist_iter; i++) ``sum += (1 + sb_rnd() % args.table_size); ``return sum / args.dist_iter; }按高斯分布取id,默认取值范围也是整个tabel_size,默认方差是12,当然方差越高,分布是越集中的.但也会导致结算量大增
这个场景下基本也是没有热门数据一说* special: 既然都不符合,那我们就来改一下sysbench让他符合Row Cache的场景.3个场景来说special最符合,只要改一行代码就可以啦 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 unsigned ``int rnd_func_special(``void``) { ``int sum = 0; ``unsigned ``int i; ``unsigned ``int d; ``unsigned ``int res; ``unsigned ``int range_size; ``if (args.table_size == 0) ``return 0; ``/* Increase range size for special values. */ ``range_size = args.table_size * (100 / (100 - args.dist_res)); ``/* Generate evenly distributed one at this stage */ ``res = (1 + sb_rnd() % range_size); ``/* For first part use gaussian distribution */ ``if (res <= args.table_size) ``{ ``for``(i = 0; i < args.dist_iter; i++) ``{ ``sum += (1 + sb_rnd() % args.table_size); ``} ``return sum / args.dist_iter; ``} ``/* ``* For second part use even distribution mapped to few items ``* We shall distribute other values near by the center ``*/ ``d = args.table_size * args.dist_pct / 100; ``if (d < 1) ``d = 1; ``res %= d; ``/* Now we have res values in SPECIAL_PCT range of the data */ ``//res += (args.table_size / 2 - args.table_size * args.dist_pct / (100 * 2)); ``res *= (100/args.dist_pct); ``//这下够离散了 ``return res; }
可以直接下载我修改好的包哦
http://code.google.com/p/row-cache-for-innodb/downloads/detail?name=sysbench-0.4.8.tar.gz&can=2&q=#makechanges
参考执行命令:
sysbench --test=oltp --oltp-test-mode=simple --oltp-skip-trx=on --oltp-table-size=80000000 --oltp-range-size=1 --mysql-host=localhost --mysql-user=xx --mysql-password=xx --oltp-read-only=on --init-rng=on --num-threads=70 --oltp-dist-type=special --oltp-dist-pct=1 --oltp-dist-res=80 --max-requests=0 --max-time=1800 run </div>本文来源于"阿里中间件团队播客",原文发表时间" 2011-09-10 "
相关资源:敏捷开发V1.0.pptx