libmemcached-1.0.18 を入れて memslap & memaslap を使えるようにする
memcached の便利ツール群(?) の libmemcached (http://libmemcached.org/libMemcached.html) を入れてみる.
libmemcached に付属しているベンチマークソフトである memslap や memaslap を使いたい.
memslap と memaslap は微妙に別物である様子.
ググってみても, memslap コマンドで現在の memaslap の出力をしてるサイトもあり, かなり混同されている?
名前も似過ぎていてわかりにくいが, 開発中に分岐したとかそんな感じなのだろうか?
前回 memcached はインストール済み.
ogaharuc.hatenablog.com
libmemcached のURLからダウンロード(http://libmemcached.org/libMemcached.html)してmake.
# apt install g++
# cd /usr/local/src/
# mkdir libmemcached
# cd libmemcached
# wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
# tar xvzf libmemcached-1.0.18.tar.gz
# cd libmemcached-1.0.18
# ./configure
# make && make install
とりあえず memaslap コマンドを打ってみる
# memslap
memslap: error while loading shared libraries: libmemcached.so.11: cannot open shared object file: No such file or directory
怒られた. No such file or directory? とりあえずググる.
共有ライブラリの依存関係情報を更新するコマンドの ldconfig とやらを使えばライブラリがリンクされるらしい.
# ldconfig
# memslap --servers=localhost:11211
Threads connecting to servers 1
Took 0.149 seconds to load data
動いている. memslap の他に, memflush や memstat も使えるようになっている.
いろいろ試してみる.
# memslap --servers=localhost:11211 --execute-number=100000
Threads connecting to servers 1
Took 1.156 seconds to load data
# memslap --servers=localhost:11211 --execute-number=300000
Threads connecting to servers 1
Took 3.788 seconds to load data
# memslap --servers=localhost:11211 --concurrency=2 --execute-number=10000
Threads connecting to servers 2
Took 0.267 seconds to load data
# memslap --servers=localhost:11211 --concurrency=2 --execute-number=100000
Threads connecting to servers 2
Took 2.732 seconds to load data
出てくるのこれだけ?と調べてみたら memaslap (http://docs.libmemcached.org/bin/memaslap.html)という強化版みたいなものがあるらしい。
ということで memslap じゃなくて memaslap を使いたい. が, このままでは memaslap は使えないようだ.
configure の時に --enable-memaslap すれば良いらしい.
# ./configure --enable-memaslap
# make && make install
(中略)
CXXLD clients/memaslap
/usr/bin/ld: clients/ms_thread.o: undefined reference to symbol 'pthread_key_delete@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:4707: recipe for target 'clients/memaslap' failed
make[1]: *** [clients/memaslap] Error 1
make[1]: Leaving directory '/usr/local/src/libmemcached/libmemcached-1.0.18'
Makefile:3700: recipe for target 'all' failed
make: *** [all] Error 2
怒られた...pthread 系のエラーらしいけど解決策がわからないので検索.
bugs.launchpad.net
バグレポートはあるらしいが, 未解決っぽい. なんだろう, ライブラリなんか入れ忘れかなあ...libmemcached-1.0.18固有のもの?
うーん, わからん!とりあえず-pthread をどこかにつければいいらしい.「memaslap 'pthread_key_delete@@GLIBC_2.2.5'」 で検索
どうやら Makefile の 2937行を LDFLAGS = -L/lib64 -lpthread にすれば良いらしい(???)
Makefile を編集.
# diff Makefile Makefile.org
2937c2937< LDFLAGS = -L/lib64 -lpthread
---
> LDFLAGS =
一応 make は通った
# memflush --servers=127.0.0.1:11211
# memaslap -s 127.0.0.1:11211
servers : 127.0.0.1:11211
threads count: 1
concurrency: 16
run time: 600s
windows size: 10k
set proportion: set_prop=0.10
get proportion: get_prop=0.90
cmd_get: 63711111
cmd_set: 7079024
get_misses: 44362628
written_bytes: 12282098170
read_bytes: 21755243702
object_bytes: 7701978112Run time: 600.0s Ops: 70790135 TPS: 117977 Net_rate: 54.1M/s
どういう出力が正しいのか検証していないのですが, とりあえず実行はできたみたい.
memslap と memaslap のオプション詳細や出力詳細については後日.
参考