Skip to content

Commit ee276ff

Browse files
Merge pull request #100 from nathanaschbacher/nathan_dev
summary.r changes, PB Search testing, and ETS testing.
2 parents 0174992 + 351b680 commit ee276ff

5 files changed

+112
-0
lines changed

examples/basho_bench_ets.config

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{mode, max}.
2+
3+
{duration, 3}.
4+
5+
{concurrent, 4}.
6+
7+
{driver, basho_bench_driver_ets}.
8+
9+
{operations, [{get,1}, {put,1}]}.
10+
11+
{key_generator, {int_to_bin_littleendian, {uniform_int, 1000}}}.
12+
13+
{value_generator, {fixed_bin, 100000}}.
14+
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{mode, max}.
2+
3+
{duration, 10}.
4+
5+
{concurrent, 3}.
6+
7+
{driver, basho_bench_driver_riakc_pb}.
8+
9+
%%{key_generator, {int_to_bin, {uniform_int, 10000}}}.
10+
%%{value_generator, {fixed_bin, 10000}}.
11+
12+
{riakc_pb_ips, [
13+
{{127,0,0,1}, 10017}, %% {Ip, Port}
14+
{{127,0,0,1}, 10027}, %% {Ip, Port}
15+
{{127,0,0,1}, [10037, 10047]} %% {Ip, Ports}
16+
]}.
17+
18+
{riakc_pb_search_queries, [{<<"index">>, "query", [{rows,10}]}]}. %% last element of the tuple is a list of Search options/params.
19+
20+
{operations, [{search, 1}]}.
21+
22+
%% {query_step_interval, 60}. %% time in seconds to run each query before switching to the next one in the list, default is 60 seconds.
23+
%% {operations, [{search_interval, 1}]}.
24+

priv/summary.r

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ latency_plot <- ggplot(b$latencies, aes(x = elapsed)) +
6161

6262
# Plot 99 and 99.9th percentiles
6363
plot2 <- latency_plot +
64+
geom_point(aes(y = X99th, color = "X99th")) +
65+
geom_point(aes(y = X99_9th, color = "X99_9th")) +
6466
geom_smooth(aes(y = X99th, color = "X99th")) +
6567
geom_smooth(aes(y = X99_9th, color = "X99_9th")) +
6668
scale_color_hue("Percentile",
@@ -70,6 +72,9 @@ plot2 <- latency_plot +
7072

7173
# Plot median, mean and 95th percentiles
7274
plot3 <- latency_plot +
75+
geom_point(aes(y = median, color = "median")) +
76+
geom_point(aes(y = mean, color = "mean")) +
77+
geom_point(aes(y = X95th, color = "X95th")) +
7378
geom_smooth(aes(y = median, color = "median")) +
7479
geom_smooth(aes(y = mean, color = "mean")) +
7580
geom_smooth(aes(y = X95th, color = "X95th")) +

src/basho_bench_driver_ets.erl

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-module(basho_bench_driver_ets).
2+
3+
-export([new/1,
4+
run/4]).
5+
6+
new(_Id) ->
7+
EtsTable = ets:new(basho_bench, [ordered_set]),
8+
{ok, EtsTable}.
9+
10+
run(get, KeyGen, _ValueGen, EtsTable) ->
11+
Start = KeyGen(),
12+
case ets:lookup(EtsTable, Start) of
13+
[] ->
14+
{ok, EtsTable};
15+
[{_Key, _Val}] ->
16+
{ok, EtsTable};
17+
Error ->
18+
{error, Error, EtsTable}
19+
end;
20+
21+
run(put, KeyGen, ValueGen, EtsTable) ->
22+
Object = {KeyGen(), ValueGen()},
23+
ets:insert(EtsTable, Object),
24+
{ok, EtsTable};
25+
26+
run(delete, KeyGen, _ValueGen, EtsTable) ->
27+
Start = KeyGen(),
28+
ets:delete(EtsTable, Start),
29+
{ok, EtsTable}.
30+

src/basho_bench_driver_riakc_pb.erl

+39
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
dw,
3737
pw,
3838
rw,
39+
search_queries,
40+
query_step_interval,
41+
start_time,
3942
keylist_length,
4043
preloaded_keys,
4144
timeout_general,
@@ -79,6 +82,8 @@ new(Id) ->
7982
RW = basho_bench_config:get(riakc_pb_rw, Replies),
8083
PW = basho_bench_config:get(riakc_pb_pw, Replies),
8184
PR = basho_bench_config:get(riakc_pb_pr, Replies),
85+
SearchQs = basho_bench_config:get(riakc_pb_search_queries, []),
86+
SearchQStepIval = basho_bench_config:get(query_step_interval, 60),
8287
Bucket = basho_bench_config:get(riakc_pb_bucket, <<"test">>),
8388
KeylistLength = basho_bench_config:get(riakc_pb_keylist_length, 1000),
8489
PreloadedKeys = basho_bench_config:get(
@@ -99,6 +104,9 @@ new(Id) ->
99104
dw = DW,
100105
rw = RW,
101106
pw = PW,
107+
search_queries = SearchQs,
108+
query_step_interval = SearchQStepIval,
109+
start_time = erlang:now(),
102110
keylist_length = KeylistLength,
103111
preloaded_keys = PreloadedKeys,
104112
timeout_general = get_timeout_general(),
@@ -230,6 +238,34 @@ run(listkeys, _KeyGen, _ValueGen, State) ->
230238
{error, Reason} ->
231239
{error, Reason, State}
232240
end;
241+
run(search, _KeyGen, _ValueGen, #state{search_queries=SearchQs}=State) ->
242+
[{Index, Query, Options}|_] = SearchQs,
243+
244+
NewState = State#state{search_queries=roll_list(SearchQs)},
245+
246+
case riakc_pb_socket:search(NewState#state.pid, Index, Query, Options, NewState#state.timeout_read) of
247+
{ok, _Results} ->
248+
{ok, NewState};
249+
{error, Reason} ->
250+
{error, Reason, NewState}
251+
end;
252+
run(search_interval, _KeyGen, _ValueGen, #state{search_queries=SearchQs, start_time=StartTime, query_step_interval=Interval}=State) ->
253+
[{Index, Query, Options}|_] = SearchQs,
254+
255+
Now = erlang:now(),
256+
case timer:now_diff(Now, StartTime) of
257+
_MicroSec when _MicroSec > (Interval * 1000000) ->
258+
NewState = State#state{search_queries=roll_list(SearchQs),start_time=Now};
259+
_MicroSec ->
260+
NewState = State
261+
end,
262+
263+
case riakc_pb_socket:search(NewState#state.pid, Index, Query, Options, NewState#state.timeout_read) of
264+
{ok, _Results} ->
265+
{ok, NewState};
266+
{error, Reason} ->
267+
{error, Reason, NewState}
268+
end;
233269
run(mr_bucket_erlang, _KeyGen, _ValueGen, State) ->
234270
mapred(State, State#state.bucket, ?ERLANG_MR);
235271
run(mr_bucket_js, _KeyGen, _ValueGen, State) ->
@@ -336,6 +372,9 @@ make_keylist(Bucket, KeyGen, Count) ->
336372
[{Bucket, list_to_binary(KeyGen())}
337373
|make_keylist(Bucket, KeyGen, Count-1)].
338374

375+
roll_list(List) ->
376+
[lists:last(List) | lists:sublist(List, length(List) - 1)].
377+
339378
mapred_valgen(_Id, MaxRand) ->
340379
fun() ->
341380
list_to_binary(integer_to_list(random:uniform(MaxRand)))

0 commit comments

Comments
 (0)