From 1c2adc0678e25897dca0877c3f147e1cde7ea247 Mon Sep 17 00:00:00 2001 From: Nathan Aschbacher Date: Fri, 13 Sep 2013 13:22:47 -0700 Subject: [PATCH 1/4] Updated R script to generate more detailed latency graphs. Useful information was being lost in the curve smoothing. --- priv/summary.r | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/priv/summary.r b/priv/summary.r index 16d0ce98f..6178b7914 100755 --- a/priv/summary.r +++ b/priv/summary.r @@ -61,6 +61,8 @@ latency_plot <- ggplot(b$latencies, aes(x = elapsed)) + # Plot 99 and 99.9th percentiles plot2 <- latency_plot + + geom_point(aes(y = X99th, color = "X99th")) + + geom_point(aes(y = X99_9th, color = "X99_9th")) + geom_smooth(aes(y = X99th, color = "X99th")) + geom_smooth(aes(y = X99_9th, color = "X99_9th")) + scale_color_hue("Percentile", @@ -70,6 +72,9 @@ plot2 <- latency_plot + # Plot median, mean and 95th percentiles plot3 <- latency_plot + + geom_point(aes(y = median, color = "median")) + + geom_point(aes(y = mean, color = "mean")) + + geom_point(aes(y = X95th, color = "X95th")) + geom_smooth(aes(y = median, color = "median")) + geom_smooth(aes(y = mean, color = "mean")) + geom_smooth(aes(y = X95th, color = "X95th")) + From e2aa693a008caa17647610821c547cc4ab5fdb44 Mon Sep 17 00:00:00 2001 From: Nathan Aschbacher Date: Fri, 13 Sep 2013 13:23:20 -0700 Subject: [PATCH 2/4] Added ETS driver and config. --- examples/basho_bench_ets.config | 14 ++++++++++++++ src/basho_bench_driver_ets.erl | 30 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 examples/basho_bench_ets.config create mode 100644 src/basho_bench_driver_ets.erl diff --git a/examples/basho_bench_ets.config b/examples/basho_bench_ets.config new file mode 100644 index 000000000..e83ac5063 --- /dev/null +++ b/examples/basho_bench_ets.config @@ -0,0 +1,14 @@ +{mode, max}. + +{duration, 3}. + +{concurrent, 4}. + +{driver, basho_bench_driver_ets}. + +{operations, [{get,1}, {put,1}]}. + +{key_generator, {int_to_bin_littleendian, {uniform_int, 1000}}}. + +{value_generator, {fixed_bin, 100000}}. + diff --git a/src/basho_bench_driver_ets.erl b/src/basho_bench_driver_ets.erl new file mode 100644 index 000000000..7316430ca --- /dev/null +++ b/src/basho_bench_driver_ets.erl @@ -0,0 +1,30 @@ +-module(basho_bench_driver_ets). + +-export([new/1, + run/4]). + +new(_Id) -> + EtsTable = ets:new(basho_bench, [ordered_set]), + {ok, EtsTable}. + +run(get, KeyGen, _ValueGen, EtsTable) -> + Start = KeyGen(), + case ets:lookup(EtsTable, Start) of + [] -> + {ok, EtsTable}; + [{_Key, _Val}] -> + {ok, EtsTable}; + Error -> + {error, Error, EtsTable} + end; + +run(put, KeyGen, ValueGen, EtsTable) -> + Object = {KeyGen(), ValueGen()}, + ets:insert(EtsTable, Object), + {ok, EtsTable}; + +run(delete, KeyGen, _ValueGen, EtsTable) -> + Start = KeyGen(), + ets:delete(EtsTable, Start), + {ok, EtsTable}. + \ No newline at end of file From 656544c09796225b4fa29f55bb4680f8e2a0f25b Mon Sep 17 00:00:00 2001 From: Nathan Aschbacher Date: Fri, 13 Sep 2013 13:25:04 -0700 Subject: [PATCH 3/4] Added search query testing to the PB driver and included an example config. Supports iterating over a list of example queries with a new query per request or on an interval where the same query is run over and over again. This is very helpful in isolating Search performance and queries that are especially bad actors. --- examples/riakc_pb.search.devrel.config | 24 ++++++++++++++++ src/basho_bench_driver_riakc_pb.erl | 39 ++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 examples/riakc_pb.search.devrel.config diff --git a/examples/riakc_pb.search.devrel.config b/examples/riakc_pb.search.devrel.config new file mode 100644 index 000000000..44cd9f3f2 --- /dev/null +++ b/examples/riakc_pb.search.devrel.config @@ -0,0 +1,24 @@ +{mode, max}. + +{duration, 10}. + +{concurrent, 3}. + +{driver, basho_bench_driver_riakc_pb}. + +%%{key_generator, {int_to_bin, {uniform_int, 10000}}}. +%%{value_generator, {fixed_bin, 10000}}. + +{riakc_pb_ips, [ + {{127,0,0,1}, 10017}, %% {Ip, Port} + {{127,0,0,1}, 10027}, %% {Ip, Port} + {{127,0,0,1}, [10037, 10047]} %% {Ip, Ports} + ]}. + +{riakc_pb_search_queries, [{<<"index">>, "query", [{rows,10}]}]}. %% last element of the tuple is a list of Search options/params. + +{operations, [{search, 1}]}. + +%% {query_step_interval, 60}. %% time in seconds to run each query before switching to the next one in the list, default is 60 seconds. +%% {operations, [{search_interval, 1}]}. + diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index c6790d527..a3c4ac733 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -36,6 +36,9 @@ dw, pw, rw, + search_queries, + query_step_interval, + start_time, keylist_length, preloaded_keys, timeout_general, @@ -79,6 +82,8 @@ new(Id) -> RW = basho_bench_config:get(riakc_pb_rw, Replies), PW = basho_bench_config:get(riakc_pb_pw, Replies), PR = basho_bench_config:get(riakc_pb_pr, Replies), + SearchQs = basho_bench_config:get(riakc_pb_search_queries, []), + SearchQStepIval = basho_bench_config:get(query_step_interval, 60), Bucket = basho_bench_config:get(riakc_pb_bucket, <<"test">>), KeylistLength = basho_bench_config:get(riakc_pb_keylist_length, 1000), PreloadedKeys = basho_bench_config:get( @@ -99,6 +104,9 @@ new(Id) -> dw = DW, rw = RW, pw = PW, + search_queries = SearchQs, + query_step_interval = SearchQStepIval, + start_time = erlang:now(), keylist_length = KeylistLength, preloaded_keys = PreloadedKeys, timeout_general = get_timeout_general(), @@ -230,6 +238,34 @@ run(listkeys, _KeyGen, _ValueGen, State) -> {error, Reason} -> {error, Reason, State} end; +run(search, _KeyGen, _ValueGen, #state{search_queries=SearchQs}=State) -> + [{Index, Query, Options}|_] = SearchQs, + + NewState = State#state{search_queries=roll_search_query_list(SearchQs)}, + + case riakc_pb_socket:search(NewState#state.pid, Index, Query, Options, NewState#state.timeout_read) of + {ok, _Results} -> + {ok, NewState}; + {error, Reason} -> + {error, Reason, NewState} + end; +run(search_interval, _KeyGen, _ValueGen, #state{search_queries=SearchQs, start_time=StartTime, query_step_interval=Interval}=State) -> + [{Index, Query, Options}|_] = SearchQs, + + Now = erlang:now(), + case timer:now_diff(Now, StartTime) of + _MicroSec when _MicroSec > (Interval * 1000000) -> + NewState = State#state{search_queries=roll_search_query_list(SearchQs),start_time=Now}; + _MicroSec -> + NewState = State + end, + + case riakc_pb_socket:search(NewState#state.pid, Index, Query, Options, NewState#state.timeout_read) of + {ok, _Results} -> + {ok, NewState}; + {error, Reason} -> + {error, Reason, NewState} + end; run(mr_bucket_erlang, _KeyGen, _ValueGen, State) -> mapred(State, State#state.bucket, ?ERLANG_MR); run(mr_bucket_js, _KeyGen, _ValueGen, State) -> @@ -336,6 +372,9 @@ make_keylist(Bucket, KeyGen, Count) -> [{Bucket, list_to_binary(KeyGen())} |make_keylist(Bucket, KeyGen, Count-1)]. +roll_search_query_list(List) -> + [lists:last(List) | lists:sublist(List, length(List) - 1)]. + mapred_valgen(_Id, MaxRand) -> fun() -> list_to_binary(integer_to_list(random:uniform(MaxRand))) From 351b680351bad535218d94afdc48db14550b9895 Mon Sep 17 00:00:00 2001 From: Nathan Aschbacher Date: Fri, 13 Sep 2013 14:06:25 -0700 Subject: [PATCH 4/4] Renamed roll_search_query_list/1 to just be roll_list/1 --- src/basho_bench_driver_riakc_pb.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index a3c4ac733..7522ce58c 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -241,7 +241,7 @@ run(listkeys, _KeyGen, _ValueGen, State) -> run(search, _KeyGen, _ValueGen, #state{search_queries=SearchQs}=State) -> [{Index, Query, Options}|_] = SearchQs, - NewState = State#state{search_queries=roll_search_query_list(SearchQs)}, + NewState = State#state{search_queries=roll_list(SearchQs)}, case riakc_pb_socket:search(NewState#state.pid, Index, Query, Options, NewState#state.timeout_read) of {ok, _Results} -> @@ -255,7 +255,7 @@ run(search_interval, _KeyGen, _ValueGen, #state{search_queries=SearchQs, start_t Now = erlang:now(), case timer:now_diff(Now, StartTime) of _MicroSec when _MicroSec > (Interval * 1000000) -> - NewState = State#state{search_queries=roll_search_query_list(SearchQs),start_time=Now}; + NewState = State#state{search_queries=roll_list(SearchQs),start_time=Now}; _MicroSec -> NewState = State end, @@ -372,7 +372,7 @@ make_keylist(Bucket, KeyGen, Count) -> [{Bucket, list_to_binary(KeyGen())} |make_keylist(Bucket, KeyGen, Count-1)]. -roll_search_query_list(List) -> +roll_list(List) -> [lists:last(List) | lists:sublist(List, length(List) - 1)]. mapred_valgen(_Id, MaxRand) ->