From a10f231595d6e20d00b49a886bd151e8c23607d4 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Thu, 8 Dec 2016 09:44:25 +0000 Subject: [PATCH 01/75] Add NHS driver (untested) Try add a driver thta does a balance of NHS style work --- examples/riakc_nhs.config | 37 +++++ src/basho_bench_driver_nhs.erl | 290 +++++++++++++++++++++++++++++++++ src/basho_bench_valgen.erl | 35 ++++ 3 files changed, 362 insertions(+) create mode 100644 examples/riakc_nhs.config create mode 100644 src/basho_bench_driver_nhs.erl diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config new file mode 100644 index 000000000..f6e429c2a --- /dev/null +++ b/examples/riakc_nhs.config @@ -0,0 +1,37 @@ +{mode, max}. + +{duration, 3600}. +{report_interval, 10}. + +{concurrent, 20}. + +{driver, basho_bench_driver_nhs}. + +{key_generator, {pareto_int, 100000000}}. + +{value_generator, {semi_compressible, 4000, 4000}}. + +{pb_ips, [{127,0,0,1}]}. +{http_ips, [{127,0,0,1}]}. + +{riakc_pb_replies, 1}. + +{operations, [{get_pb, 200}, {update_with2i, 50}, {put_unique, 10}, + {postcodequery_http, 3}, {dobquery_http, 1}]}. + +%% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). +%% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. +{pb_connect_options, [{auto_reconnect, true}]}. + +%% Overrides for the PB client's default 60 second timeout, on a +%% per-type-of-operation basis. All timeout units are specified in +%% milliseconds. The pb_timeout_general config item provides a +%% default timeout if the read/write/listkeys/mapreduce timeout is not +%% specified. + +{pb_timeout_general, 30000}. +{pb_timeout_read, 5000}. +{pb_timeout_write, 5000}. +{pb_timeout_listkeys, 50000}. +%% The general timeout will be used because this specific item is commented: +%% {pb_timeout_mapreduce, 50000}. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl new file mode 100644 index 000000000..eba335593 --- /dev/null +++ b/src/basho_bench_driver_nhs.erl @@ -0,0 +1,290 @@ +%% ------------------------------------------------------------------- +%% +%% basho_bench_driver_2i_nhs: Driver for NHS-like workloads +%% +%% Copyright (c) 2009 Basho Techonologies +%% +%% This file is provided to you under the Apache License, +%% Version 2.0 (the "License"); you may not use this file +%% except in compliance with the License. You may obtain +%% a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, +%% software distributed under the License is distributed on an +%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +%% KIND, either express or implied. See the License for the +%% specific language governing permissions and limitations +%% under the License. +%% +%% ------------------------------------------------------------------- +-module(basho_bench_driver_nhs). + +-export([new/1, + run/4]). + +-include("basho_bench.hrl"). + +-record(state, { + pb_pid, + http_host, + http_port, + recordBucket, + docBucket, + pb_timeout, + http_timeout + }). + +-define(POSTCODE_AREAS, + [{1, "AB"}, {2, "AL"}, {3, "B", {4, "BA", {5, "BB"}, {6, "BD"}, + {7, "BH"}, {8, "BL"}, {9, "BN"}, {10, "BR"}, {11, "BS"}, + {12, "BT"}, {13, "CA"}, {14, "CB"}, {15, "CF"}, {16, "CH"}, + {17, "CM"}, {18, "CO"}, {19, "CR"}, {20, "CT"}, {21, "CV"}, + {22, "CW"}, {23, "DA"}, {24, "DD"}, {25, "DE"}, {26, "DG"}, + {27, "DH"}, {28, "DL"}, {29, "DN"}, {30, "DT"}, {31, "DU"}, + {32, "E"}, {33, "EC"}, {34, "EH"}, {35, "EN"}, {36, "EX"}, + {37, "FK"}, {38, "FY"}, {39, "G"}, {40, "GL"}, {41, "GU"}, + {42, "HA"}, {43, "HD"}, {44, "HG"}, {45, "HP"}, {46, "HR"}, + {47, "HS"}, {48, "HU"}, {49, "HX"}, {50, "IG"}, {51, "IP"}, + {52, "IV"}, {53, "KA"}, {54, "KT"}, {55, "KW"}, {56, "KY"}, + {57, "L"}, {58, "LA"}, {59, "LD"}, {60, "LE"}, {61, "LL"}, + {62, "LS"}, {63, "LU"}, {64, "M"}, {65, "ME"}, {66, "MK"}, + {67, "ML"}, {68, "N"}, {69, "NE"}, {70, "NG"}, {71, "MM"}, + {72, "NP"}, {73, "NR"}, {74, "NW"}, {75, "OL"}, {76, "OX"}]). +-define(DATETIME_FORMAT, "~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w"). +-define(DATE_FORMAT, "~b-~2..0b-~2..0b"). + +%% ==================================================================== +%% API +%% ==================================================================== + +new(Id) -> + %% Ensure that ibrowse is started... + application:start(ibrowse), + + %% Ensure that riakc library is in the path... + ensure_module(riakc_pb_socket), + ensure_module(mochijson2), + + %% Read config settings... + PBIPs = basho_bench_config:get(pb_ips, ["127.0.0.1"]), + PBPort = basho_bench_config:get(pb_port, 8087), + HTTPIPs = basho_bench_config:get(http_ips, ["127.0.0.1"]), + HTTPPort = basho_bench_config:get(http_port, 8098), + + PBTimeout = basho_bench_config:get(pb_timeout_general, 30*1000), + HTTPTimeout = basho_bench_config:get(http_timeout_general, 30*1000), + + %% Choose the target node using our ID as a modulus + HTTPTargets = basho_bench_config:normalize_ips(HTTPIPs, HTTPPort), + {HTTPTargetIp, + HTTPTargetPort} = lists:nth((Id rem length(HTTPTargets) + 1), + HTTPTargets), + ?INFO("Using http target ~p:~p for worker ~p\n", [HTTPTargetIp, + HTTPTargetPort, + Id]), + + %% Choose the target node using our ID as a modulus + PBTargets = basho_bench_config:normalize_ips(PBIPs, PBPort), + {PBTargetIp, + PBTargetPort} = lists:nth((Id rem length(PBTargets) + 1), + PBTargets), + ?INFO("Using pb target ~p:~p for worker ~p\n", [PBTargetIp, + PBTargetPort, + Id]), + + case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of + {ok, Pid} -> + {ok, #state { + pb_pid = Pid, + http_host = HTTPTargetIp, + http_port = HTTPTargetPort, + recordBucket = <<"domainRecord">>, + documentBucket = <<"domainDocument">>, + pb_timeout = PBTimeout, + http_timeout = HTTPTimeout}}; + {error, Reason2} -> + ?FAIL_MSG("Failed to connect riakc_pb_socket to ~p port ~p: ~p\n", + [PBTargetIp, PBTargetPort, Reason2]) + end. + +%% Get a single object. +run(get_pb, KeyGen, _ValueGen, State) -> + Pid = State#state.pb_pid, + Bucket = State#state.recordBucket, + Key = to_binary(KeyGen()), + case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of + {ok, _Obj} -> + {ok, State}; + {error, notfound} -> + {ok, State}; + {error, Reason} -> + {error, Reason, State} + end; + +%% Update an object with secondary indexes. +run(update_with2i, KeyGen, ValueGen, State) -> + Pid = State#state.pb_pid, + Bucket = State#state.recordBucket, + Key = to_binary(KeyGen()), + Value = ValueGen(), + + Robj0 = + case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of + {ok, Robj} -> + RObj; + {error, notfound} -> + riak_object:new(Bucket, Key) + end, + + MD0 = riakc_obj:get_update_metadata(Robj0), + MD1 = riakc_obj:clear_scondary_indexes(MD0), + MD2 = riakc_obj:set_secondary_index(MD1, generate_binary_indexes()), + Robj1 = riakc_obj:update_value(Robj0, Value), + Robj2 = riakc_obj:update_metadata(Robj1, MD2), + + %% Write the object... + case riakc_pb_socket:put(Pid, Robj2, State#state.pb_timeout) of + ok -> + {ok, State}; + {error, Reason} -> + {error, Reason, State} + end; +%% Put an object with a unique key and a non-compressable value +run(put_unique, _KeyGen, _ValueGen, State) -> + Pid = State#state.pb_pid, + Bucket = State#state.recordBucket, + + Key = generate_uniquekey(), + Value = non_compressible_value(6000), + + Robj0 = riak_object:new(Bucket, Key) + MD0 = riakc_obj:get_update_metadata(Robj0), + MD2 = riakc_obj:set_secondary_index(MD1, generate_binary_indexes()), + Robj1 = riakc_obj:update_value(Robj0, Value), + Robj2 = riakc_obj:update_metadata(Robj1, MD2), + + %% Write the object... + case riakc_pb_socket:put(Pid, Robj2, State#state.pb_timeout) of + ok -> + {ok, State}; + {error, Reason} -> + {error, Reason, State} + end; + +%% Query results via the HTTP interface. +run(postcodequery_http, _KeyGen, _ValueGen, State) -> + Host = State#state.http_host, + Port = State#state.http_port, + Bucket = State#state.recordBucket, + + L = length(?POSTCODE_AREAS), + Area = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), + District = Area ++ integer_to_list(random:uniform(26)), + StartKey = District ++ "|" ++ "a", + EndKey = District ++ "|" ++ "b", + URL = io_lib:format("http://~s:~p/buckets/~s/index/postcode_bin/~s/~s", + [Host, Port, Bucket, StartKey, EndKey]), + + case json_get(URL, State) of + {ok, {struct, Proplist}} -> + Results = proplists:get_value(<<"keys">>, Proplist), + io:format("PostC query results of length ~w~n", length(Results)), + {ok, State}; + {error, Reason} -> + io:format("[~s:~p] ERROR - Reason: ~p~n", + [?MODULE, ?LINE, Reason]), + {error, Reason, State} + end; + +%% Query results via the HTTP interface. +run(dobquery_http, _KeyGen, _ValueGen, State) -> + Host = State#state.http_host, + Port = State#state.http_port, + Bucket = State#state.recordBucket, + + Rand Year = random:uniform(70) + 1950, + DoBStart = integer_to_list(RandYear) ++ "0101", + DoBEnd = integer_to_list(RandYear) ++ "0110", + + URLSrc = "http://~s:~p/buckets/~s/index/postcode_bin/~s/~s?term_regex=~s", + URL = io_lib:format(URLSrc, + [Host, Port, Bucket, DoBStart, DoBEnd, "[0-9]{8}\|a"]), + + case json_get(URL, State) of + {ok, {struct, Proplist}} -> + Results = proplists:get_value(<<"keys">>, Proplist), + io:format("DoB query results of length ~w~n", length(Results)), + {ok, State}; + {error, Reason} -> + io:format("[~s:~p] ERROR - Reason: ~p~n", + [?MODULE, ?LINE, Reason]), + {error, Reason, State} + end; + +run(Other, _, _, _) -> + throw({unknown_operation, Other}). + +%% ==================================================================== +%% Internal functions +%% ==================================================================== + +json_get(Url, State) -> + Response = ibrowse:send_req(lists:flatten(Url), [], get, + [], [], State#state.pb_timeout), + case Response of + {ok, "200", _, Body} -> + {ok, mochijson2:decode(Body)}; + Other -> + {error, Other} + end. + + +%% ==================================================================== +%% Index seeds +%% ==================================================================== + +generate_binary_indexes() -> + [{{binary_index, "postcode"}, postcode_index()}, + {{binary_index, "dateofbirth"}, dateofbirth_index()}, + {{binary_index, "lastmodified"}, lastmodified_index()}]. + +postcode_index() -> + NotVeryNameLikeThing = base64:encode_to_string(crypto:rand_bytes(4)), + lists:map(fun(_X) -> + L = length(?POSTCODE_AREAS), + Area = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), + District = Area ++ integer_to_list(random:uniform(26)), + F = District ++ "|" ++ NotVeryNameLikeThing, + list_to_binary(F) end, + lists:seq(1, random:uniform(3))). + +dateofbirth_index() -> + Delta = random:uniform(2500000000), + {{Y, M, D}, + _} = calendar:gregorian_seconds_to_datetime(Delta + 61000000000), + F = lists:flatten(io_lib:format(?DATE_FORMAT, [Y, M, D])) ++ "|" ++ + base64::encode_to_string(crypto:rand_bytes(4)), + [list_to_binary(F)]. + +lastmodified_index() -> + {{Year, Month, Day}, + {Hr, Min, Sec}} = calendar:now_to_datetime(os:timestamp()), + F = lists:flatten(io_lib:format(?DATETIME_FORMAT, + [Year, Month, Day, Hr, Min, Sec])), + [lists_to_binary(F)]. + + +generate_uniquekey() -> + {{Year, Month, Day}, + {Hr, Min, Sec}} = calendar:now_to_datetime(os:timestamp()), + F = lists:flatten(io_lib:format(?DATETIME_FORMAT, + [Year, Month, Day, Hr, Min, Sec])), + F ++ [base64:encode_to_string(crypto:rand_bytes(4))], + list_to_binary(F). + +non_compressable_value(Size) -> + crypto:rand_bytes(Size). + + diff --git a/src/basho_bench_valgen.erl b/src/basho_bench_valgen.erl index a211701a5..462bee60a 100644 --- a/src/basho_bench_valgen.erl +++ b/src/basho_bench_valgen.erl @@ -64,6 +64,18 @@ new({uniform_int, MaxVal}, _Id) new({uniform_int, MinVal, MaxVal}, _Id) when is_integer(MinVal), is_integer(MaxVal), MaxVal > MinVal -> fun() -> random:uniform(MinVal, MaxVal) end; +new({semi_compressible, MinSize, MeanSize}, Id) + when is_integer(MinSize), MinSize >= 0, is_number(Mean), Mean > 0 -> + Source1 = init_source(Id), + RandomStrs = lists:map(fun(X) -> + SL = lists:map(fun(_X) -> + random:uniform(95) + 31 + end, + lists:seq(1, 128)), + {X, list_to_binary(SL)} end, + lists:seq(1, 16)), + VSize = MinSize + trunc(-math:log(random:uniform()) * Mean), + fun() -> semi_compressible_value(VSize, RandomStrs, Source1) end; new(Other, _Id) -> ?FAIL_MSG("Invalid value generator requested: ~p\n", [Other]). @@ -115,3 +127,26 @@ data_block({SourceCfg, SourceSz, Source}, BlockSize) -> [SourceCfg, SourceSz, BlockSize]), Source end. + +semi_compressible_value(Size, + RandomStrings, + {SourceCfg, SourceSz, Source}) -> + CompressibleSize = (Size div 3) * 2, + Chunks = CompressibleSize div 128, + CompressiblePart = random_binary(Chunks, + <<>>, + length(RandomStrings), + RandomStrings), + UncompressibleSize = Size - byte_size(CompressiblePart), + UncompressiblePart = date_block({SourceCfg, SourceSz, Source}, + UncompressibleSize), + <>. + +random_binary(0, RandomBin, _StringCount, _RandomStrings) -> + RandomBin; +random_binary(Chunks, RandomBin, StringCount, RandomStrings) -> + {_R, Bin} = lists:keyfind(random:uniform(StringCount), 1 RandomStrings), + random_binary(Chunks - 1, + <>, + Stringcount, + RandomStrings). From a5797866383ec1ec87d201892e7b054f6870c26d Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 14 Dec 2016 16:37:52 +0000 Subject: [PATCH 02/75] Add First draft of NHS changes --- examples/riakc_pb.config | 16 ++++----- src/basho_bench_driver_nhs.erl | 63 +++++++++++++++++++++------------- src/basho_bench_valgen.erl | 8 ++--- 3 files changed, 52 insertions(+), 35 deletions(-) diff --git a/examples/riakc_pb.config b/examples/riakc_pb.config index 02ec6ad75..f740ff367 100644 --- a/examples/riakc_pb.config +++ b/examples/riakc_pb.config @@ -1,22 +1,22 @@ {mode, max}. -{duration, 10}. -{report_interval,1}. +{duration, 60}. +{report_interval,10}. -{concurrent, 10}. +{concurrent, 6}. {driver, basho_bench_driver_riakc_pb}. -{key_generator, {int_to_bin_bigendian, {uniform_int, 10000}}}. +{key_generator, {int_to_bin_bigendian, {uniform_int, 10000000}}}. -{value_generator, {fixed_bin, 10000}}. +{value_generator, {fixed_bin, 8000}}. {riakc_pb_ips, [{127,0,0,1}]}. {riakc_pb_replies, 1}. %%% {operations, [{get, 1}]}. -{operations, [{get, 1}, {update, 1}]}. +{operations, [{update, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. @@ -29,8 +29,8 @@ %% specified. {pb_timeout_general, 30000}. -{pb_timeout_read, 5000}. -{pb_timeout_write, 5000}. +{pb_timeout_read, 10000}. +{pb_timeout_write, 10000}. {pb_timeout_listkeys, 50000}. %% The general timeout will be used because this specific item is commented: %% {pb_timeout_mapreduce, 50000}. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index eba335593..487489a7d 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -31,27 +31,28 @@ http_host, http_port, recordBucket, - docBucket, + documentBucket, pb_timeout, http_timeout }). -define(POSTCODE_AREAS, - [{1, "AB"}, {2, "AL"}, {3, "B", {4, "BA", {5, "BB"}, {6, "BD"}, - {7, "BH"}, {8, "BL"}, {9, "BN"}, {10, "BR"}, {11, "BS"}, - {12, "BT"}, {13, "CA"}, {14, "CB"}, {15, "CF"}, {16, "CH"}, - {17, "CM"}, {18, "CO"}, {19, "CR"}, {20, "CT"}, {21, "CV"}, - {22, "CW"}, {23, "DA"}, {24, "DD"}, {25, "DE"}, {26, "DG"}, - {27, "DH"}, {28, "DL"}, {29, "DN"}, {30, "DT"}, {31, "DU"}, - {32, "E"}, {33, "EC"}, {34, "EH"}, {35, "EN"}, {36, "EX"}, - {37, "FK"}, {38, "FY"}, {39, "G"}, {40, "GL"}, {41, "GU"}, - {42, "HA"}, {43, "HD"}, {44, "HG"}, {45, "HP"}, {46, "HR"}, - {47, "HS"}, {48, "HU"}, {49, "HX"}, {50, "IG"}, {51, "IP"}, - {52, "IV"}, {53, "KA"}, {54, "KT"}, {55, "KW"}, {56, "KY"}, - {57, "L"}, {58, "LA"}, {59, "LD"}, {60, "LE"}, {61, "LL"}, - {62, "LS"}, {63, "LU"}, {64, "M"}, {65, "ME"}, {66, "MK"}, - {67, "ML"}, {68, "N"}, {69, "NE"}, {70, "NG"}, {71, "MM"}, - {72, "NP"}, {73, "NR"}, {74, "NW"}, {75, "OL"}, {76, "OX"}]). + [{1, "AB"}, {2, "AL"}, {3, "B"}, {4, "BA"}, {5, "BB"}, + {6, "BD"}, {7, "BH"}, {8, "BL"}, {9, "BN"}, {10, "BR"}, + {11, "BS"}, {12, "BT"}, {13, "CA"}, {14, "CB"}, {15, "CF"}, + {16, "CH"}, {17, "CM"}, {18, "CO"}, {19, "CR"}, {20, "CT"}, + {21, "CV"}, {22, "CW"}, {23, "DA"}, {24, "DD"}, {25, "DE"}, + {26, "DG"}, {27, "DH"}, {28, "DL"}, {29, "DN"}, {30, "DT"}, + {31, "DU"}, {32, "E"}, {33, "EC"}, {34, "EH"}, {35, "EN"}, + {36, "EX"}, {37, "FK"}, {38, "FY"}, {39, "G"}, {40, "GL"}, + {41, "GU"}, {42, "HA"}, {43, "HD"}, {44, "HG"}, {45, "HP"}, + {46, "HR"}, {47, "HS"}, {48, "HU"}, {49, "HX"}, {50, "IG"}, + {51, "IP"}, {52, "IV"}, {53, "KA"}, {54, "KT"}, {55, "KW"}, + {56, "KY"}, {57, "L"}, {58, "LA"}, {59, "LD"}, {60, "LE"}, + {61, "LL"}, {62, "LS"}, {63, "LU"}, {64, "M"}, {65, "ME"}, + {66, "MK"}, {67, "ML"}, {68, "N"}, {69, "NE"}, {70, "NG"}, + {71, "MM"}, {72, "NP"}, {73, "NR"}, {74, "NW"}, {75, "OL"}, + {76, "OX"}]). -define(DATETIME_FORMAT, "~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w"). -define(DATE_FORMAT, "~b-~2..0b-~2..0b"). @@ -133,7 +134,7 @@ run(update_with2i, KeyGen, ValueGen, State) -> Robj0 = case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of {ok, Robj} -> - RObj; + Robj; {error, notfound} -> riak_object:new(Bucket, Key) end, @@ -159,8 +160,8 @@ run(put_unique, _KeyGen, _ValueGen, State) -> Key = generate_uniquekey(), Value = non_compressible_value(6000), - Robj0 = riak_object:new(Bucket, Key) - MD0 = riakc_obj:get_update_metadata(Robj0), + Robj0 = riak_object:new(Bucket, Key), + MD1 = riakc_obj:get_update_metadata(Robj0), MD2 = riakc_obj:set_secondary_index(MD1, generate_binary_indexes()), Robj1 = riakc_obj:update_value(Robj0, Value), Robj2 = riakc_obj:update_metadata(Robj1, MD2), @@ -204,7 +205,7 @@ run(dobquery_http, _KeyGen, _ValueGen, State) -> Port = State#state.http_port, Bucket = State#state.recordBucket, - Rand Year = random:uniform(70) + 1950, + RandYear = random:uniform(70) + 1950, DoBStart = integer_to_list(RandYear) ++ "0101", DoBEnd = integer_to_list(RandYear) ++ "0110", @@ -240,6 +241,22 @@ json_get(Url, State) -> {error, Other} end. +to_binary(B) when is_binary(B) -> + B; +to_binary(I) when is_integer(I) -> + list_to_binary(integer_to_list(I)); +to_binary(L) when is_list(L) -> + list_to_binary(L). + +ensure_module(Module) -> + case code:which(Module) of + non_existing -> + ?FAIL_MSG("~s requires " ++ atom_to_list(Module) ++ + " module to be available on code path.\n", + [?MODULE]); + _ -> + ok + end. %% ==================================================================== %% Index seeds @@ -265,7 +282,7 @@ dateofbirth_index() -> {{Y, M, D}, _} = calendar:gregorian_seconds_to_datetime(Delta + 61000000000), F = lists:flatten(io_lib:format(?DATE_FORMAT, [Y, M, D])) ++ "|" ++ - base64::encode_to_string(crypto:rand_bytes(4)), + base64:encode_to_string(crypto:rand_bytes(4)), [list_to_binary(F)]. lastmodified_index() -> @@ -273,7 +290,7 @@ lastmodified_index() -> {Hr, Min, Sec}} = calendar:now_to_datetime(os:timestamp()), F = lists:flatten(io_lib:format(?DATETIME_FORMAT, [Year, Month, Day, Hr, Min, Sec])), - [lists_to_binary(F)]. + [list_to_binary(F)]. generate_uniquekey() -> @@ -284,7 +301,7 @@ generate_uniquekey() -> F ++ [base64:encode_to_string(crypto:rand_bytes(4))], list_to_binary(F). -non_compressable_value(Size) -> +non_compressible_value(Size) -> crypto:rand_bytes(Size). diff --git a/src/basho_bench_valgen.erl b/src/basho_bench_valgen.erl index 462bee60a..6be3799fb 100644 --- a/src/basho_bench_valgen.erl +++ b/src/basho_bench_valgen.erl @@ -64,7 +64,7 @@ new({uniform_int, MaxVal}, _Id) new({uniform_int, MinVal, MaxVal}, _Id) when is_integer(MinVal), is_integer(MaxVal), MaxVal > MinVal -> fun() -> random:uniform(MinVal, MaxVal) end; -new({semi_compressible, MinSize, MeanSize}, Id) +new({semi_compressible, MinSize, Mean}, Id) when is_integer(MinSize), MinSize >= 0, is_number(Mean), Mean > 0 -> Source1 = init_source(Id), RandomStrs = lists:map(fun(X) -> @@ -138,15 +138,15 @@ semi_compressible_value(Size, length(RandomStrings), RandomStrings), UncompressibleSize = Size - byte_size(CompressiblePart), - UncompressiblePart = date_block({SourceCfg, SourceSz, Source}, + UncompressiblePart = data_block({SourceCfg, SourceSz, Source}, UncompressibleSize), <>. random_binary(0, RandomBin, _StringCount, _RandomStrings) -> RandomBin; random_binary(Chunks, RandomBin, StringCount, RandomStrings) -> - {_R, Bin} = lists:keyfind(random:uniform(StringCount), 1 RandomStrings), + {_R, Bin} = lists:keyfind(random:uniform(StringCount), 1, RandomStrings), random_binary(Chunks - 1, <>, - Stringcount, + StringCount, RandomStrings). From b0bd9e82ce9b397c073a0a57310ff09497dbe203 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Fri, 3 Mar 2017 09:59:53 +0000 Subject: [PATCH 03/75] Switch example --- examples/riakc_pb.config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/riakc_pb.config b/examples/riakc_pb.config index 02ec6ad75..064eda64f 100644 --- a/examples/riakc_pb.config +++ b/examples/riakc_pb.config @@ -7,16 +7,16 @@ {driver, basho_bench_driver_riakc_pb}. -{key_generator, {int_to_bin_bigendian, {uniform_int, 10000}}}. +{key_generator, {pareto_int, 100000000}}. -{value_generator, {fixed_bin, 10000}}. +{value_generator, {semi_compressible, 4000, 4000}}. {riakc_pb_ips, [{127,0,0,1}]}. {riakc_pb_replies, 1}. -%%% {operations, [{get, 1}]}. -{operations, [{get, 1}, {update, 1}]}. +{operations, [{get_pb, 1}, {update_with2i, 1}, {put_unique, 1}, + {postcodequery_http, 1}, {dobquery_http, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. From 824d559a9562d1317d43ebc81f1481759fe29c76 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Sat, 4 Mar 2017 14:34:19 +0000 Subject: [PATCH 04/75] Work on semi-compressible objects --- src/basho_bench_valgen.erl | 92 +++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/src/basho_bench_valgen.erl b/src/basho_bench_valgen.erl index 6be3799fb..cef35227b 100644 --- a/src/basho_bench_valgen.erl +++ b/src/basho_bench_valgen.erl @@ -66,16 +66,11 @@ new({uniform_int, MinVal, MaxVal}, _Id) fun() -> random:uniform(MinVal, MaxVal) end; new({semi_compressible, MinSize, Mean}, Id) when is_integer(MinSize), MinSize >= 0, is_number(Mean), Mean > 0 -> - Source1 = init_source(Id), - RandomStrs = lists:map(fun(X) -> - SL = lists:map(fun(_X) -> - random:uniform(95) + 31 - end, - lists:seq(1, 128)), - {X, list_to_binary(SL)} end, - lists:seq(1, 16)), - VSize = MinSize + trunc(-math:log(random:uniform()) * Mean), - fun() -> semi_compressible_value(VSize, RandomStrs, Source1) end; + Source1 = init_altsource(Id), + fun() -> + data_block(Source, + MinSize + trunc(basho_bench_stats:exponential(1 / Mean))) + end; new(Other, _Id) -> ?FAIL_MSG("Invalid value generator requested: ~p\n", [Other]). @@ -116,37 +111,50 @@ init_source(Id, Path) -> end, {?VAL_GEN_BLOB_CFG, size(Bin), Bin}. -data_block({SourceCfg, SourceSz, Source}, BlockSize) -> - case SourceSz - BlockSize > 0 of - true -> - Offset = random:uniform(SourceSz - BlockSize), - <<_:Offset/bytes, Slice:BlockSize/bytes, _Rest/binary>> = Source, - Slice; - false -> - ?WARN("~p is too small ~p < ~p\n", - [SourceCfg, SourceSz, BlockSize]), - Source - end. +init_altsource(Id) -> + init_altsource(Id, basho_bench_config:get(?VAL_GEN_BLOB_CFG, undefined)). + +init_altsource(1, undefined) -> + SourceSz = basho_bench_config:get(?VAL_GEN_SRC_SIZE, 96*1048576), + ?INFO("Random source: calling crypto:rand_bytes(~w) (override with the '~w' config option\n", [SourceSz, ?VAL_GEN_SRC_SIZE]), + GenRandStrFun = fun(_X) -> random:uniform(95) + 31 end, + RandomStrs = + lists:map(fun(X) -> + SL = lists:map(GenRandStrFun, lists:seq(1, 128)), + {X, list_to_binary(SL)} + end, + lists:seq(1, 16)), + ComboBlockFun = + fun(_X, Acc) = + Bin1 = crypto_randbytes(4096), + Bin2 = create_random_textblock(16, RandomStrs), + <> + end, + Bytes = lists:foldl(ComboBlockFun, <<>>, lists:seq(1, 8192)), + try + ?TAB = ets:new(?TAB, [public, named_table]), + true = ets:insert(?TAB, {x, Bytes}) + catch _:_ -> rerunning_id_1_init_source_table_already_exists + end, + ?INFO("Random source: finished crypto:rand_bytes(~w)\n", [SourceSz]), + {?VAL_GEN_SRC_SIZE, SourceSz, Bytes}; +init_altsource(_Id, undefined) -> + [{_, Bytes}] = ets:lookup(?TAB, x), + {?VAL_GEN_SRC_SIZE, size(Bytes), Bytes}; +init_altsource(Id, Path) -> + {Path, {ok, Bin}} = {Path, file:read_file(Path)}, + if Id == 1 -> ?DEBUG("path source ~p ~p\n", [size(Bin), Path]); + true -> ok + end, + {?VAL_GEN_BLOB_CFG, size(Bin), Bin}. -semi_compressible_value(Size, - RandomStrings, - {SourceCfg, SourceSz, Source}) -> - CompressibleSize = (Size div 3) * 2, - Chunks = CompressibleSize div 128, - CompressiblePart = random_binary(Chunks, - <<>>, - length(RandomStrings), - RandomStrings), - UncompressibleSize = Size - byte_size(CompressiblePart), - UncompressiblePart = data_block({SourceCfg, SourceSz, Source}, - UncompressibleSize), - <>. +create_random_textblock(BlockLength, RandomStrs) -> + GetRandomBlockFun = + fun(X, Acc) -> + random:uniform(min(X, 16)), + {Rand, Block} = lists:keyfind(Rand, 1, RandomStrs), + <> + end, + lists:foldl(GetRandomBlockFun, <<>>, lists:seq(1, BlockLength)). + -random_binary(0, RandomBin, _StringCount, _RandomStrings) -> - RandomBin; -random_binary(Chunks, RandomBin, StringCount, RandomStrings) -> - {_R, Bin} = lists:keyfind(random:uniform(StringCount), 1, RandomStrings), - random_binary(Chunks - 1, - <>, - StringCount, - RandomStrings). From 866ae2d15c526c63fb17d45b82d40117a7ce666d Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sat, 4 Mar 2017 14:41:10 +0000 Subject: [PATCH 05/75] Compile issues resolved --- src/basho_bench_valgen.erl | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/basho_bench_valgen.erl b/src/basho_bench_valgen.erl index cef35227b..98df38233 100644 --- a/src/basho_bench_valgen.erl +++ b/src/basho_bench_valgen.erl @@ -66,7 +66,7 @@ new({uniform_int, MinVal, MaxVal}, _Id) fun() -> random:uniform(MinVal, MaxVal) end; new({semi_compressible, MinSize, Mean}, Id) when is_integer(MinSize), MinSize >= 0, is_number(Mean), Mean > 0 -> - Source1 = init_altsource(Id), + Source = init_altsource(Id), fun() -> data_block(Source, MinSize + trunc(basho_bench_stats:exponential(1 / Mean))) @@ -125,8 +125,8 @@ init_altsource(1, undefined) -> end, lists:seq(1, 16)), ComboBlockFun = - fun(_X, Acc) = - Bin1 = crypto_randbytes(4096), + fun(_X, Acc) -> + Bin1 = crypto:rand_bytes(4096), Bin2 = create_random_textblock(16, RandomStrs), <> end, @@ -151,10 +151,22 @@ init_altsource(Id, Path) -> create_random_textblock(BlockLength, RandomStrs) -> GetRandomBlockFun = fun(X, Acc) -> - random:uniform(min(X, 16)), + Rand = random:uniform(min(X, 16)), {Rand, Block} = lists:keyfind(Rand, 1, RandomStrs), <> end, lists:foldl(GetRandomBlockFun, <<>>, lists:seq(1, BlockLength)). + +data_block({SourceCfg, SourceSz, Source}, BlockSize) -> + case SourceSz - BlockSize > 0 of + true -> + Offset = random:uniform(SourceSz - BlockSize), + <<_:Offset/bytes, Slice:BlockSize/bytes, _Rest/binary>> = Source, + Slice; + false -> + ?WARN("~p is too small ~p < ~p\n", + [SourceCfg, SourceSz, BlockSize]), + Source + end. From be9706c0e0f9120fd562f17d472f113004a6e547 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sun, 5 Mar 2017 21:43:28 +0000 Subject: [PATCH 06/75] Alter valgen to emit SourceSz correctly --- src/basho_bench_valgen.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/basho_bench_valgen.erl b/src/basho_bench_valgen.erl index 98df38233..1a8891399 100644 --- a/src/basho_bench_valgen.erl +++ b/src/basho_bench_valgen.erl @@ -115,8 +115,6 @@ init_altsource(Id) -> init_altsource(Id, basho_bench_config:get(?VAL_GEN_BLOB_CFG, undefined)). init_altsource(1, undefined) -> - SourceSz = basho_bench_config:get(?VAL_GEN_SRC_SIZE, 96*1048576), - ?INFO("Random source: calling crypto:rand_bytes(~w) (override with the '~w' config option\n", [SourceSz, ?VAL_GEN_SRC_SIZE]), GenRandStrFun = fun(_X) -> random:uniform(95) + 31 end, RandomStrs = lists:map(fun(X) -> @@ -131,12 +129,13 @@ init_altsource(1, undefined) -> <> end, Bytes = lists:foldl(ComboBlockFun, <<>>, lists:seq(1, 8192)), + SourceSz = byte_size(Bytes), try ?TAB = ets:new(?TAB, [public, named_table]), true = ets:insert(?TAB, {x, Bytes}) catch _:_ -> rerunning_id_1_init_source_table_already_exists end, - ?INFO("Random source: finished crypto:rand_bytes(~w)\n", [SourceSz]), + ?INFO("Finished generating random source size (~w)\n", [SourceSz]), {?VAL_GEN_SRC_SIZE, SourceSz, Bytes}; init_altsource(_Id, undefined) -> [{_, Bytes}] = ets:lookup(?TAB, x), From f384c09ff70a01c4076e88af77770cca2195d35e Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sun, 5 Mar 2017 22:53:02 +0000 Subject: [PATCH 07/75] Add 2i support --- src/basho_bench_driver_riakc_pb.erl | 94 ++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index 7338dd2af..3e265af5d 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -58,6 +58,26 @@ [{map, {jsfun, <<"Riak.mapValuesJson">>}, none, false}, {reduce, {jsfun, <<"Riak.reduceSum">>}, none, true}]). +-define(POSTCODE_AREAS, + [{1, "AB"}, {2, "AL"}, {3, "B"}, {4, "BA"}, {5, "BB"}, + {6, "BD"}, {7, "BH"}, {8, "BL"}, {9, "BN"}, {10, "BR"}, + {11, "BS"}, {12, "BT"}, {13, "CA"}, {14, "CB"}, {15, "CF"}, + {16, "CH"}, {17, "CM"}, {18, "CO"}, {19, "CR"}, {20, "CT"}, + {21, "CV"}, {22, "CW"}, {23, "DA"}, {24, "DD"}, {25, "DE"}, + {26, "DG"}, {27, "DH"}, {28, "DL"}, {29, "DN"}, {30, "DT"}, + {31, "DU"}, {32, "E"}, {33, "EC"}, {34, "EH"}, {35, "EN"}, + {36, "EX"}, {37, "FK"}, {38, "FY"}, {39, "G"}, {40, "GL"}, + {41, "GU"}, {42, "HA"}, {43, "HD"}, {44, "HG"}, {45, "HP"}, + {46, "HR"}, {47, "HS"}, {48, "HU"}, {49, "HX"}, {50, "IG"}, + {51, "IP"}, {52, "IV"}, {53, "KA"}, {54, "KT"}, {55, "KW"}, + {56, "KY"}, {57, "L"}, {58, "LA"}, {59, "LD"}, {60, "LE"}, + {61, "LL"}, {62, "LS"}, {63, "LU"}, {64, "M"}, {65, "ME"}, + {66, "MK"}, {67, "ML"}, {68, "N"}, {69, "NE"}, {70, "NG"}, + {71, "MM"}, {72, "NP"}, {73, "NR"}, {74, "NW"}, {75, "OL"}, + {76, "OX"}]). +-define(DATETIME_FORMAT, "~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w"). +-define(DATE_FORMAT, "~b-~2..0b-~2..0b"). + %% ==================================================================== %% API %% ==================================================================== @@ -109,7 +129,7 @@ new(Id) -> content_type = CT, search_queries = SearchQs, query_step_interval = SearchQStepIval, - start_time = erlang:now(), + start_time = erlang:timestamp(), keylist_length = KeylistLength, preloaded_keys = PreloadedKeys, timeout_general = get_timeout_general(), @@ -346,6 +366,38 @@ run(update, KeyGen, ValueGen, State) -> {error, Reason} -> {error, Reason, State} end; + +%% Update an object with secondary indexes. +run(update_with2i, KeyGen, ValueGen, State) -> + Pid = State#state.pid, + Key = KeyGen(), + Value = ValueGen(), + + Robj0 = + case riakc_pb_socket:get(Pid, + State#state.bucket, + Key, + State#state.timeout_read) of + {ok, Robj} -> + Robj; + {error, notfound} -> + riak_object:new(State#state.bucket, Key) + end, + + MD0 = riakc_obj:get_update_metadata(Robj0), + MD1 = riakc_obj:clear_scondary_indexes(MD0), + MD2 = riakc_obj:set_secondary_index(MD1, generate_binary_indexes()), + Robj1 = riakc_obj:update_value(Robj0, Value), + Robj2 = riakc_obj:update_metadata(Robj1, MD2), + + %% Write the object... + case riakc_pb_socket:put(Pid, Robj2, State#state.timeout_write) of + ok -> + {ok, State}; + {error, Reason} -> + {error, Reason, State} + end; + run(update_existing, KeyGen, ValueGen, State) -> Key = KeyGen(), case riakc_pb_socket:get(State#state.pid, State#state.bucket, @@ -409,7 +461,7 @@ run(search, _KeyGen, _ValueGen, #state{search_queries=SearchQs}=State) -> run(search_interval, _KeyGen, _ValueGen, #state{search_queries=SearchQs, start_time=StartTime, query_step_interval=Interval}=State) -> [{Index, Query, Options}|_] = SearchQs, - Now = erlang:now(), + Now = erlang:timestamp(), case timer:now_diff(Now, StartTime) of _MicroSec when _MicroSec > (Interval * 1000000) -> NewState = State#state{search_queries=roll_list(SearchQs),start_time=Now}; @@ -609,3 +661,41 @@ get_timeout(Name) when Name == pb_timeout_read; get_connect_options() -> basho_bench_config:get(pb_connect_options, [{auto_reconnect, true}]). + + +%% ==================================================================== +%% Index seeds +%% ==================================================================== + + +generate_binary_indexes() -> + [{{binary_index, "postcode"}, postcode_index()}, + {{binary_index, "dateofbirth"}, dateofbirth_index()}, + {{binary_index, "lastmodified"}, lastmodified_index()}]. + +postcode_index() -> + NotVeryNameLikeThing = base64:encode_to_string(crypto:rand_bytes(4)), + lists:map(fun(_X) -> + L = length(?POSTCODE_AREAS), + Area = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), + District = Area ++ integer_to_list(random:uniform(26)), + F = District ++ "|" ++ NotVeryNameLikeThing, + list_to_binary(F) end, + lists:seq(1, random:uniform(3))). + +dateofbirth_index() -> + Delta = random:uniform(2500000000), + {{Y, M, D}, + _} = calendar:gregorian_seconds_to_datetime(Delta + 61000000000), + F = lists:flatten(io_lib:format(?DATE_FORMAT, [Y, M, D])) ++ "|" ++ + base64:encode_to_string(crypto:rand_bytes(4)), + [list_to_binary(F)]. + +lastmodified_index() -> + {{Year, Month, Day}, + {Hr, Min, Sec}} = calendar:now_to_datetime(os:timestamp()), + F = lists:flatten(io_lib:format(?DATETIME_FORMAT, + [Year, Month, Day, Hr, Min, Sec])), + [list_to_binary(F)]. + + From 00409c636085c930d55f7ad99a3c9195325e974e Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sun, 5 Mar 2017 23:35:24 +0000 Subject: [PATCH 08/75] Add 2i query --- src/basho_bench_driver_riakc_pb.erl | 33 ++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index 3e265af5d..da7ace03b 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -129,7 +129,7 @@ new(Id) -> content_type = CT, search_queries = SearchQs, query_step_interval = SearchQStepIval, - start_time = erlang:timestamp(), + start_time = os:timestamp(), keylist_length = KeylistLength, preloaded_keys = PreloadedKeys, timeout_general = get_timeout_general(), @@ -381,11 +381,11 @@ run(update_with2i, KeyGen, ValueGen, State) -> {ok, Robj} -> Robj; {error, notfound} -> - riak_object:new(State#state.bucket, Key) + riakc_obj:new(State#state.bucket, Key) end, MD0 = riakc_obj:get_update_metadata(Robj0), - MD1 = riakc_obj:clear_scondary_indexes(MD0), + MD1 = riakc_obj:clear_secondary_indexes(MD0), MD2 = riakc_obj:set_secondary_index(MD1, generate_binary_indexes()), Robj1 = riakc_obj:update_value(Robj0, Value), Robj2 = riakc_obj:update_metadata(Robj1, MD2), @@ -398,6 +398,29 @@ run(update_with2i, KeyGen, ValueGen, State) -> {error, Reason, State} end; +run(query_postcode, _KeyGen, _ValueGen, State) -> + Pid = State#state.pid, + Bucket = State#state.bucket, + L = length(?POSTCODE_AREAS), + {_R, Area} = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), + District = Area ++ integer_to_list(random:uniform(26)), + StartKey = District ++ "|" ++ "a", + EndKey = District ++ "|" ++ "b", + case riakc_pb_socket:get_index(Pid, + Bucket, + <<"postcode_bin">>, + list_to_binary(StartKey), + list_to_binary(EndKey), + State#state.timeout_general, + State#state.timeout_general) of + {ok, Results} -> + io:format("2i query returned ~w results~n", [length(Results)]), + {ok, State}; + {error, Reason} -> + io:format("[~s:~p] ERROR - Reason: ~p~n", [?MODULE, ?LINE, Reason]), + {error, Reason, State} + end; + run(update_existing, KeyGen, ValueGen, State) -> Key = KeyGen(), case riakc_pb_socket:get(State#state.pid, State#state.bucket, @@ -461,7 +484,7 @@ run(search, _KeyGen, _ValueGen, #state{search_queries=SearchQs}=State) -> run(search_interval, _KeyGen, _ValueGen, #state{search_queries=SearchQs, start_time=StartTime, query_step_interval=Interval}=State) -> [{Index, Query, Options}|_] = SearchQs, - Now = erlang:timestamp(), + Now = os:timestamp(), case timer:now_diff(Now, StartTime) of _MicroSec when _MicroSec > (Interval * 1000000) -> NewState = State#state{search_queries=roll_list(SearchQs),start_time=Now}; @@ -677,7 +700,7 @@ postcode_index() -> NotVeryNameLikeThing = base64:encode_to_string(crypto:rand_bytes(4)), lists:map(fun(_X) -> L = length(?POSTCODE_AREAS), - Area = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), + {_R, Area} = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), District = Area ++ integer_to_list(random:uniform(26)), F = District ++ "|" ++ NotVeryNameLikeThing, list_to_binary(F) end, From c083dd47dfa70558dd35a6821e2ef62a672546b8 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sun, 5 Mar 2017 23:50:24 +0000 Subject: [PATCH 09/75] Switch to non-deprecated get_index_range --- src/basho_bench_driver_riakc_pb.erl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index da7ace03b..eea1fd4cd 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -406,15 +406,16 @@ run(query_postcode, _KeyGen, _ValueGen, State) -> District = Area ++ integer_to_list(random:uniform(26)), StartKey = District ++ "|" ++ "a", EndKey = District ++ "|" ++ "b", - case riakc_pb_socket:get_index(Pid, - Bucket, - <<"postcode_bin">>, - list_to_binary(StartKey), - list_to_binary(EndKey), - State#state.timeout_general, - State#state.timeout_general) of + case riakc_pb_socket:get_index_range(Pid, + Bucket, + <<"postcode_bin">>, + list_to_binary(StartKey), + list_to_binary(EndKey), + [{timeout, State#state.timeout_general}, + {return_terms, true}]) of {ok, Results} -> - io:format("2i query returned ~w results~n", [length(Results)]), + {results, ResultList} = Results, + io:format("2i query returned ~w results~n", [length(ResultList)]), {ok, State}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", [?MODULE, ?LINE, Reason]), From 96dd85683715f11e2a30bf942a806ae53e8c8528 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sun, 5 Mar 2017 23:56:51 +0000 Subject: [PATCH 10/75] adjust format of results format is not as suggested in erlang client code comments --- src/basho_bench_driver_riakc_pb.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index eea1fd4cd..9c201a750 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -414,7 +414,7 @@ run(query_postcode, _KeyGen, _ValueGen, State) -> [{timeout, State#state.timeout_general}, {return_terms, true}]) of {ok, Results} -> - {results, ResultList} = Results, + {index_results_v1, undefined, ResultList, undefined} = Results, io:format("2i query returned ~w results~n", [length(ResultList)]), {ok, State}; {error, Reason} -> From dec1a38a538873fe29b3d87cd07c0d0b68304fd0 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 6 Mar 2017 00:02:26 +0000 Subject: [PATCH 11/75] Does empty results have a different look? --- src/basho_bench_driver_riakc_pb.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index 9c201a750..c6221724a 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -414,8 +414,13 @@ run(query_postcode, _KeyGen, _ValueGen, State) -> [{timeout, State#state.timeout_general}, {return_terms, true}]) of {ok, Results} -> - {index_results_v1, undefined, ResultList, undefined} = Results, - io:format("2i query returned ~w results~n", [length(ResultList)]), + case Results of + {index_results_v1, undefined, ResultList, undefined} -> + io:format("2i query returned ~w results~n", [length(ResultList)]), + ok; + _ -> + ok + end, {ok, State}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", [?MODULE, ?LINE, Reason]), From 1cb5b7a49e6596261fa411b4e44c2effda524166 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Thu, 16 Mar 2017 17:42:18 +0000 Subject: [PATCH 12/75] Untested extension of 2i query --- src/basho_bench_driver_riakc_pb.erl | 79 ++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index c6221724a..103dde46f 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -46,11 +46,16 @@ timeout_read, timeout_write, timeout_listkeys, - timeout_mapreduce + timeout_mapreduce, + twoi_qcount = 0 :: integer(), + twoi_rcount = 0 :: integer() }). -define(TIMEOUT_GENERAL, 62*1000). % Riak PB default + 2 sec +% the bigger the number the less frequent the logs of 2i query results +-define(RANDOMLOG_FREQ, 5000). + -define(ERLANG_MR, [{map, {modfun, riak_kv_mapreduce, map_object_value}, none, false}, {reduce, {modfun, riak_kv_mapreduce, reduce_count_inputs}, none, true}]). @@ -414,14 +419,24 @@ run(query_postcode, _KeyGen, _ValueGen, State) -> [{timeout, State#state.timeout_general}, {return_terms, true}]) of {ok, Results} -> - case Results of - {index_results_v1, undefined, ResultList, undefined} -> - io:format("2i query returned ~w results~n", [length(ResultList)]), - ok; - _ -> - ok - end, - {ok, State}; + record_2i_results(Results, State); + {error, Reason} -> + io:format("[~s:~p] ERROR - Reason: ~p~n", [?MODULE, ?LINE, Reason]), + {error, Reason, State} + end; +run(query_dob, _KeyGen, _ValueGen, State) -> + R = random:uniform(2500000000), + DOB_SK = pick_dateofbirth(R), + DOB_EK = pick_dateofbirth(R + random:uniform(86400 * 2)), + case riakc_pb_socket:get_index_range(Pid, + Bucket, + <<"dateofbirth_bin">>, + list_to_binary(DOB_SK), + list_to_binary(DOB=EK), + [{timeout, State#state.timeout_general}, + {return_terms, true}]) of + {ok, Results} -> + record_2i_results(Results, State); {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", [?MODULE, ?LINE, Reason]), {error, Reason, State} @@ -713,13 +728,18 @@ postcode_index() -> lists:seq(1, random:uniform(3))). dateofbirth_index() -> - Delta = random:uniform(2500000000), - {{Y, M, D}, - _} = calendar:gregorian_seconds_to_datetime(Delta + 61000000000), - F = lists:flatten(io_lib:format(?DATE_FORMAT, [Y, M, D])) ++ "|" ++ + F = pick_dateofbirth() ++ "|" ++ base64:encode_to_string(crypto:rand_bytes(4)), [list_to_binary(F)]. +pick_dateofbirth() -> + pick_dateofbirth(random:uniform(2500000000)). + +pick_dateofbirth(Delta) -> + {{Y, M, D}, + _} = calendar:gregorian_seconds_to_datetime(Delta + 61000000000), + lists:flatten(io_lib:format(?DATE_FORMAT, [Y, M, D])). + lastmodified_index() -> {{Year, Month, Day}, {Hr, Min, Sec}} = calendar:now_to_datetime(os:timestamp()), @@ -728,3 +748,36 @@ lastmodified_index() -> [list_to_binary(F)]. +record_2i_results(Results, State) -> + RCount_ThisQuery = + case Results of + {index_results_v1, undefined, ResultList, undefined} -> + length(ResultList); + _ -> + 0 + end, + QCount = State#state.twoi_qcount + 1, + RCount = State#state.twoi_rcount + RCount_ThisQuery, + case random:uniform(?RANDOMLOG_FREQ) < QCount of + true -> + AvgRSize = RCount / QCount, + TS = timer:now_diff(os:timestamp(), + State#state.start_time) / 1000000, + io:format("After ~w seconds average result size of ~.2f", + [AvgRSize]), + {ok, State#state{twoi_qcount = 0, twoi_rcount = 0}}; + false -> + {ok, State#state{twoi_qcount = QCount, twoi_rcount = RCount}} + end. + +format_time() -> + format_time(localtime_ms()). + +localtime_ms() -> + {_, _, Micro} = Now = os:timestamp(), + {Date, {Hours, Minutes, Seconds}} = calendar:now_to_local_time(Now), + {Date, {Hours, Minutes, Seconds, Micro div 1000 rem 1000}}. + +format_time({{Y, M, D}, {H, Mi, S, Ms}}) -> + io_lib:format("~b-~2..0b-~2..0b", [Y, M, D]) ++ "T" ++ + io_lib:format("~2..0b:~2..0b:~2..0b.~3..0b", [H, Mi, S, Ms]). From 5ba29fbc8d2213de8e53653dc737d437e3004508 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Thu, 16 Mar 2017 18:05:44 +0000 Subject: [PATCH 13/75] Compile fix #1 --- src/basho_bench_driver_riakc_pb.erl | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index 103dde46f..d191fff54 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -425,6 +425,8 @@ run(query_postcode, _KeyGen, _ValueGen, State) -> {error, Reason, State} end; run(query_dob, _KeyGen, _ValueGen, State) -> + Pid = State#state.pid, + Bucket = State#state.bucket, R = random:uniform(2500000000), DOB_SK = pick_dateofbirth(R), DOB_EK = pick_dateofbirth(R + random:uniform(86400 * 2)), @@ -432,7 +434,7 @@ run(query_dob, _KeyGen, _ValueGen, State) -> Bucket, <<"dateofbirth_bin">>, list_to_binary(DOB_SK), - list_to_binary(DOB=EK), + list_to_binary(DOB_EK), [{timeout, State#state.timeout_general}, {return_terms, true}]) of {ok, Results} -> @@ -764,20 +766,8 @@ record_2i_results(Results, State) -> TS = timer:now_diff(os:timestamp(), State#state.start_time) / 1000000, io:format("After ~w seconds average result size of ~.2f", - [AvgRSize]), + [TS, AvgRSize]), {ok, State#state{twoi_qcount = 0, twoi_rcount = 0}}; false -> {ok, State#state{twoi_qcount = QCount, twoi_rcount = RCount}} end. - -format_time() -> - format_time(localtime_ms()). - -localtime_ms() -> - {_, _, Micro} = Now = os:timestamp(), - {Date, {Hours, Minutes, Seconds}} = calendar:now_to_local_time(Now), - {Date, {Hours, Minutes, Seconds, Micro div 1000 rem 1000}}. - -format_time({{Y, M, D}, {H, Mi, S, Ms}}) -> - io_lib:format("~b-~2..0b-~2..0b", [Y, M, D]) ++ "T" ++ - io_lib:format("~2..0b:~2..0b:~2..0b.~3..0b", [H, Mi, S, Ms]). From f8a1e36830368a2e940ce0ec120c5ced0c57be4e Mon Sep 17 00:00:00 2001 From: martinsumner Date: Thu, 16 Mar 2017 18:46:45 +0000 Subject: [PATCH 14/75] Improve logging of query results --- src/basho_bench_driver_riakc_pb.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index d191fff54..f7f995973 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -54,7 +54,7 @@ -define(TIMEOUT_GENERAL, 62*1000). % Riak PB default + 2 sec % the bigger the number the less frequent the logs of 2i query results --define(RANDOMLOG_FREQ, 5000). +-define(RANDOMLOG_FREQ, 50000). -define(ERLANG_MR, [{map, {modfun, riak_kv_mapreduce, map_object_value}, none, false}, @@ -429,12 +429,12 @@ run(query_dob, _KeyGen, _ValueGen, State) -> Bucket = State#state.bucket, R = random:uniform(2500000000), DOB_SK = pick_dateofbirth(R), - DOB_EK = pick_dateofbirth(R + random:uniform(86400 * 2)), + DOB_EK = pick_dateofbirth(R + random:uniform(86400 * 3)), case riakc_pb_socket:get_index_range(Pid, Bucket, <<"dateofbirth_bin">>, list_to_binary(DOB_SK), - list_to_binary(DOB_EK), + list_to_binary(DOB_EK ++ "~"), [{timeout, State#state.timeout_general}, {return_terms, true}]) of {ok, Results} -> @@ -765,7 +765,7 @@ record_2i_results(Results, State) -> AvgRSize = RCount / QCount, TS = timer:now_diff(os:timestamp(), State#state.start_time) / 1000000, - io:format("After ~w seconds average result size of ~.2f", + io:format("After ~w seconds average result size of ~.2f~n", [TS, AvgRSize]), {ok, State#state{twoi_qcount = 0, twoi_rcount = 0}}; false -> From e33bb726cc0c6824934819b74e2dc6dc0ed367e7 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Tue, 30 May 2017 21:47:27 +0100 Subject: [PATCH 15/75] Add eighty-twenty KeyGen To give a balance between uniform int and pareto int --- src/basho_bench_keygen.erl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/basho_bench_keygen.erl b/src/basho_bench_keygen.erl index 943705437..6ff1c3bf4 100644 --- a/src/basho_bench_keygen.erl +++ b/src/basho_bench_keygen.erl @@ -110,6 +110,16 @@ new({uniform_int, MaxKey}, _Id) new({uniform_int, StartKey, NumKeys}, _Id) when is_integer(StartKey), is_integer(NumKeys), NumKeys > 0 -> fun() -> random:uniform(NumKeys) + StartKey - 1 end; +new({eightytwenty_int, MaxKey}, _Id) when is_integer(MaxKey), MaxKey > 0 -> + fun() -> + Step = MaxKey div 5, + case random:uniform() < 0.8 of + true -> + random:uniform(Step); + false -> + Step + random:uniform(Step * 4) + end + end; new({pareto_int, MaxKey}, _Id) when is_integer(MaxKey), MaxKey > 0 -> pareto(trunc(MaxKey * 0.2), ?PARETO_SHAPE); From a4d1ffed4979e994c25c7cae74aaf575ff16bc43 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Wed, 31 May 2017 11:55:26 +0100 Subject: [PATCH 16/75] Alternate chart script Fixed y axis, as well as simplified layout --- priv/summary_ii.r | 129 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 priv/summary_ii.r diff --git a/priv/summary_ii.r b/priv/summary_ii.r new file mode 100644 index 000000000..0d54cf147 --- /dev/null +++ b/priv/summary_ii.r @@ -0,0 +1,129 @@ +#!/usr/bin/env Rscript + +# Parse the --file= argument out of command line args and +# determine where base directory is so that we can source +# our common sub-routines +arg0 <- sub("--file=(.*)", "\\1", grep("--file=", commandArgs(), value = TRUE)) +dir0 <- dirname(arg0) +source(file.path(dir0, "common.r")) + +theme_set(theme_grey(base_size = 17)) + +# Setup parameters for the script +params = matrix(c( + 'help', 'h', 0, "logical", + 'width', 'x', 2, "integer", + 'height', 'y', 2, "integer", + 'outfile', 'o', 2, "character", + 'indir', 'i', 2, "character", + 'tstart', '1', 2, "integer", + 'tend', '2', 2, "integer", + 'ylabel1stgraph', 'Y', 2, "character", + 'title', 't', 2, "character" + ), ncol=4, byrow=TRUE) + +# Parse the parameters +opt = getopt(params) + +if (!is.null(opt$help)) + { + cat(paste(getopt(params, command = basename(arg0), usage = TRUE))) + q(status=1) + } + +# Initialize defaults for opt +if (is.null(opt$width)) { opt$width = 1280 } +if (is.null(opt$height)) { opt$height = 960 } +if (is.null(opt$indir)) { opt$indir = "current"} +if (is.null(opt$outfile)) { opt$outfile = file.path(opt$indir, "summary.png") } +if (is.null(opt$ylabel1stgraph)) { opt$ylabel1stgraph = "Ops/sec" } +if (is.null(opt$title)) { opt$title = "Throughput" } + +# Load the benchmark data, passing the time-index range we're interested in +b = load_benchmark(opt$indir, opt$tstart, opt$tend) + +# If there is no actual data available, bail +if (nrow(b$latencies) == 0) +{ + stop("No latency information available to analyze in ", opt$indir) +} + +png(file = opt$outfile, width = opt$width, height = opt$height) + +# First plot req/sec from summary +plot1 <- qplot(elapsed, successful / window, data = b$summary, + geom = c("smooth", "point"), + xlab = "Elapsed Secs", ylab = opt$ylabel1stgraph, + main = opt$title) + + + ylim(0, 25000) + + + geom_smooth(aes(y = successful / window, colour = "ok"), size=0.5) + + geom_point(aes(y = successful / window, colour = "ok"), size=2.0) + + + scale_colour_manual("Response", values = c("#188125")) + + +# Setup common elements of the latency plots +latency_plot <- ggplot(b$latencies, aes(x = elapsed)) + + facet_grid(. ~ op) + + labs(x = "Elapsed Secs", y = "Latency (ms)") + +# Plot median, mean and 95th percentiles +plot2 <- latency_plot + labs(title = "Mean and Median Latency") + + + ylim(0, 100) + + + geom_smooth(aes(y = median, color = "median"), size=0.5) + + + geom_smooth(aes(y = mean, color = "mean"), size=0.5) + + + + scale_colour_manual("Percentile", values = c("#009D91", "#FFA700")) + # scale_color_hue("Percentile", + # breaks = c("X95th", "mean", "median"), + # labels = c("95th", "Mean", "Median")) + +# Plot 99th percentile +plot3 <- latency_plot + labs(title = "99th Percentile Latency") + + + ylim(0, 5000) + + + geom_smooth(aes(y = X99th, color = "99th"), size=0.5) + + geom_point(aes(y = X99th, color = "99th"), size=2.0) + + scale_colour_manual("Percentile", values = c("#FF665F", "#009D91")) + # scale_color_hue("Percentile", + # breaks = c("X99_9th","X99th" ), + # labels = c("99.9th", "99th")) + +# Plot 99.9th percentile +# plot4 <- latency_plot + labs(title = "99.9th Percentile Latency") + +# +# ylim(0, 2000) + +# +# geom_smooth(aes(y = X99_9th, color = "99.9th"), size=0.5) + +# geom_point(aes(y = X99_9th, color = "99.9th"), size=2.0) + +# scale_colour_manual("Percentile", values = c("#FF665F", "#009D91", "#FFA700")) + +# Plot 100th percentile +plot5 <- latency_plot + labs(title = "Maximum Latency") + + + ylim(0, 10000) + + + geom_smooth(aes(y = max, color = "max"), size=0.5) + + geom_point(aes(y = max, color = "max"), size=2.0) + + scale_colour_manual("Percentile", values = c("#FF665F", "#009D91", "#FFA700")) + +grid.newpage() + +pushViewport(viewport(layout = grid.layout(4, 1))) + +vplayout <- function(x,y) viewport(layout.pos.row = x, layout.pos.col = y) + +print(plot1, vp = vplayout(1,1)) +print(plot2, vp = vplayout(2,1)) +print(plot3, vp = vplayout(3,1)) +# print(plot4, vp = vplayout(4,1)) +print(plot5, vp = vplayout(4,1)) + +dev.off() From 49e663013abee4741df8c67657ad86a6e1f1546a Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 27 Jul 2017 13:11:41 +0100 Subject: [PATCH 17/75] Add listkeys support to test including logging of stop and start --- examples/riakc_pb.config | 20 +++++--- src/basho_bench_driver_riakc_pb.erl | 75 +++++++++++++++-------------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/examples/riakc_pb.config b/examples/riakc_pb.config index 2318c24e1..5c82ec7be 100644 --- a/examples/riakc_pb.config +++ b/examples/riakc_pb.config @@ -1,22 +1,30 @@ {mode, max}. -{duration, 60}. -{report_interval,10}. +{duration, 10}. +{report_interval, 1}. {concurrent, 10}. {driver, basho_bench_driver_riakc_pb}. -{key_generator, {pareto_int, 200000000}}. +{key_generator, + {concat_binary, + {base64, + {int_to_bin_bigendian, + {pareto_int, 200000000} + } + }, + <<>>} +}. -{value_generator, {semi_compressible, 4000, 4000}}. +{value_generator, {semi_compressible, 4000, 8000}}. {riakc_pb_ips, [{127,0,0,1}]}. {riakc_pb_replies, 1}. %%% {operations, [{get, 1}]}. -{operations, [{get, 5}, {update, 1}]}. +{operations, [{get, 50000000}, {update, 10000000}, {listkeys, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. @@ -31,6 +39,6 @@ {pb_timeout_general, 30000}. {pb_timeout_read, 10000}. {pb_timeout_write, 10000}. -{pb_timeout_listkeys, 50000}. +{pb_timeout_listkeys, 3600000}. %% The general timeout will be used because this specific item is commented: %% {pb_timeout_mapreduce, 50000}. diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index f7f995973..4551d776e 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -54,7 +54,7 @@ -define(TIMEOUT_GENERAL, 62*1000). % Riak PB default + 2 sec % the bigger the number the less frequent the logs of 2i query results --define(RANDOMLOG_FREQ, 50000). +-define(RANDOMLOG_FREQ, 50000). -define(ERLANG_MR, [{map, {modfun, riak_kv_mapreduce, map_object_value}, none, false}, @@ -64,21 +64,21 @@ {reduce, {jsfun, <<"Riak.reduceSum">>}, none, true}]). -define(POSTCODE_AREAS, - [{1, "AB"}, {2, "AL"}, {3, "B"}, {4, "BA"}, {5, "BB"}, - {6, "BD"}, {7, "BH"}, {8, "BL"}, {9, "BN"}, {10, "BR"}, - {11, "BS"}, {12, "BT"}, {13, "CA"}, {14, "CB"}, {15, "CF"}, - {16, "CH"}, {17, "CM"}, {18, "CO"}, {19, "CR"}, {20, "CT"}, - {21, "CV"}, {22, "CW"}, {23, "DA"}, {24, "DD"}, {25, "DE"}, - {26, "DG"}, {27, "DH"}, {28, "DL"}, {29, "DN"}, {30, "DT"}, - {31, "DU"}, {32, "E"}, {33, "EC"}, {34, "EH"}, {35, "EN"}, - {36, "EX"}, {37, "FK"}, {38, "FY"}, {39, "G"}, {40, "GL"}, - {41, "GU"}, {42, "HA"}, {43, "HD"}, {44, "HG"}, {45, "HP"}, - {46, "HR"}, {47, "HS"}, {48, "HU"}, {49, "HX"}, {50, "IG"}, - {51, "IP"}, {52, "IV"}, {53, "KA"}, {54, "KT"}, {55, "KW"}, - {56, "KY"}, {57, "L"}, {58, "LA"}, {59, "LD"}, {60, "LE"}, - {61, "LL"}, {62, "LS"}, {63, "LU"}, {64, "M"}, {65, "ME"}, - {66, "MK"}, {67, "ML"}, {68, "N"}, {69, "NE"}, {70, "NG"}, - {71, "MM"}, {72, "NP"}, {73, "NR"}, {74, "NW"}, {75, "OL"}, + [{1, "AB"}, {2, "AL"}, {3, "B"}, {4, "BA"}, {5, "BB"}, + {6, "BD"}, {7, "BH"}, {8, "BL"}, {9, "BN"}, {10, "BR"}, + {11, "BS"}, {12, "BT"}, {13, "CA"}, {14, "CB"}, {15, "CF"}, + {16, "CH"}, {17, "CM"}, {18, "CO"}, {19, "CR"}, {20, "CT"}, + {21, "CV"}, {22, "CW"}, {23, "DA"}, {24, "DD"}, {25, "DE"}, + {26, "DG"}, {27, "DH"}, {28, "DL"}, {29, "DN"}, {30, "DT"}, + {31, "DU"}, {32, "E"}, {33, "EC"}, {34, "EH"}, {35, "EN"}, + {36, "EX"}, {37, "FK"}, {38, "FY"}, {39, "G"}, {40, "GL"}, + {41, "GU"}, {42, "HA"}, {43, "HD"}, {44, "HG"}, {45, "HP"}, + {46, "HR"}, {47, "HS"}, {48, "HU"}, {49, "HX"}, {50, "IG"}, + {51, "IP"}, {52, "IV"}, {53, "KA"}, {54, "KT"}, {55, "KW"}, + {56, "KY"}, {57, "L"}, {58, "LA"}, {59, "LD"}, {60, "LE"}, + {61, "LL"}, {62, "LS"}, {63, "LU"}, {64, "M"}, {65, "ME"}, + {66, "MK"}, {67, "ML"}, {68, "N"}, {69, "NE"}, {70, "NG"}, + {71, "MM"}, {72, "NP"}, {73, "NR"}, {74, "NW"}, {75, "OL"}, {76, "OX"}]). -define(DATETIME_FORMAT, "~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w"). -define(DATE_FORMAT, "~b-~2..0b-~2..0b"). @@ -377,18 +377,18 @@ run(update_with2i, KeyGen, ValueGen, State) -> Pid = State#state.pid, Key = KeyGen(), Value = ValueGen(), - + Robj0 = - case riakc_pb_socket:get(Pid, - State#state.bucket, - Key, + case riakc_pb_socket:get(Pid, + State#state.bucket, + Key, State#state.timeout_read) of {ok, Robj} -> Robj; {error, notfound} -> riakc_obj:new(State#state.bucket, Key) end, - + MD0 = riakc_obj:get_update_metadata(Robj0), MD1 = riakc_obj:clear_secondary_indexes(MD0), MD2 = riakc_obj:set_secondary_index(MD1, generate_binary_indexes()), @@ -411,10 +411,10 @@ run(query_postcode, _KeyGen, _ValueGen, State) -> District = Area ++ integer_to_list(random:uniform(26)), StartKey = District ++ "|" ++ "a", EndKey = District ++ "|" ++ "b", - case riakc_pb_socket:get_index_range(Pid, - Bucket, + case riakc_pb_socket:get_index_range(Pid, + Bucket, <<"postcode_bin">>, - list_to_binary(StartKey), + list_to_binary(StartKey), list_to_binary(EndKey), [{timeout, State#state.timeout_general}, {return_terms, true}]) of @@ -430,11 +430,11 @@ run(query_dob, _KeyGen, _ValueGen, State) -> R = random:uniform(2500000000), DOB_SK = pick_dateofbirth(R), DOB_EK = pick_dateofbirth(R + random:uniform(86400 * 3)), - case riakc_pb_socket:get_index_range(Pid, - Bucket, + case riakc_pb_socket:get_index_range(Pid, + Bucket, <<"dateofbirth_bin">>, - list_to_binary(DOB_SK), - list_to_binary(DOB_EK ++ "~"), + list_to_binary(DOB_SK), + list_to_binary(DOB_EK ++ "|"), [{timeout, State#state.timeout_general}, {return_terms, true}]) of {ok, Results} -> @@ -482,9 +482,12 @@ run(delete, KeyGen, _ValueGen, State) -> {error, Reason, State} end; run(listkeys, _KeyGen, _ValueGen, State) -> - %% Pass on rw - case riakc_pb_socket:list_keys(State#state.pid, State#state.bucket, State#state.timeout_listkeys) of - {ok, _Keys} -> + lager:info("Commencing listkeys request"), + case riakc_pb_socket:list_keys(State#state.pid, + State#state.bucket, + State#state.timeout_listkeys) of + {ok, Keys} -> + lager:info("listkeys request returned ~w keys", [length(Keys)]), {ok, State}; {error, disconnected} -> run(listkeys, _KeyGen, _ValueGen, State); @@ -511,7 +514,7 @@ run(search_interval, _KeyGen, _ValueGen, #state{search_queries=SearchQs, start_t case timer:now_diff(Now, StartTime) of _MicroSec when _MicroSec > (Interval * 1000000) -> NewState = State#state{search_queries=roll_list(SearchQs),start_time=Now}; - _MicroSec -> + _MicroSec -> NewState = State end, @@ -721,7 +724,7 @@ generate_binary_indexes() -> postcode_index() -> NotVeryNameLikeThing = base64:encode_to_string(crypto:rand_bytes(4)), - lists:map(fun(_X) -> + lists:map(fun(_X) -> L = length(?POSTCODE_AREAS), {_R, Area} = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), District = Area ++ integer_to_list(random:uniform(26)), @@ -748,11 +751,11 @@ lastmodified_index() -> F = lists:flatten(io_lib:format(?DATETIME_FORMAT, [Year, Month, Day, Hr, Min, Sec])), [list_to_binary(F)]. - + record_2i_results(Results, State) -> - RCount_ThisQuery = - case Results of + RCount_ThisQuery = + case Results of {index_results_v1, undefined, ResultList, undefined} -> length(ResultList); _ -> From 9b4a998f866879760f40ade43cc804d34f56dbf0 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 27 Jul 2017 14:45:42 +0100 Subject: [PATCH 18/75] Randomise listkeys request Cannot use listkeys stats, and so will log timer for each listkeys separately --- examples/riakc_pb.config | 2 +- src/basho_bench_driver_riakc_pb.erl | 38 ++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/examples/riakc_pb.config b/examples/riakc_pb.config index 5c82ec7be..552105000 100644 --- a/examples/riakc_pb.config +++ b/examples/riakc_pb.config @@ -24,7 +24,7 @@ {riakc_pb_replies, 1}. %%% {operations, [{get, 1}]}. -{operations, [{get, 50000000}, {update, 10000000}, {listkeys, 1}]}. +{operations, [{get, 50000}, {update, 10000}, {listkeys, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index 4551d776e..6e1c1f0fb 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -48,7 +48,8 @@ timeout_listkeys, timeout_mapreduce, twoi_qcount = 0 :: integer(), - twoi_rcount = 0 :: integer() + twoi_rcount = 0 :: integer(), + listkeys_prob :: float() }). -define(TIMEOUT_GENERAL, 62*1000). % Riak PB default + 2 sec @@ -82,6 +83,7 @@ {76, "OX"}]). -define(DATETIME_FORMAT, "~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w"). -define(DATE_FORMAT, "~b-~2..0b-~2..0b"). +-define(LISTKEYS_PROBABILITY, 0.001). %% ==================================================================== %% API @@ -123,6 +125,7 @@ new(Id) -> ?INFO("Using target ~p:~p for worker ~p\n", [TargetIp, TargetPort, Id]), case riakc_pb_socket:start_link(TargetIp, TargetPort, get_connect_options()) of {ok, Pid} -> + random:seed(), {ok, #state { pid = Pid, bucket = Bucket, r = R, @@ -137,6 +140,7 @@ new(Id) -> start_time = os:timestamp(), keylist_length = KeylistLength, preloaded_keys = PreloadedKeys, + listkeys_prob = ?LISTKEYS_PROBABILITY, timeout_general = get_timeout_general(), timeout_read = get_timeout(pb_timeout_read), timeout_write = get_timeout(pb_timeout_write), @@ -482,17 +486,29 @@ run(delete, KeyGen, _ValueGen, State) -> {error, Reason, State} end; run(listkeys, _KeyGen, _ValueGen, State) -> - lager:info("Commencing listkeys request"), - case riakc_pb_socket:list_keys(State#state.pid, - State#state.bucket, - State#state.timeout_listkeys) of - {ok, Keys} -> - lager:info("listkeys request returned ~w keys", [length(Keys)]), + case random:uniform() > State#state.listkeys_prob of + true -> + % Skip the listkeys + % Note that we cannot use the stats from listkeys, as most of + % them are now null operations {ok, State}; - {error, disconnected} -> - run(listkeys, _KeyGen, _ValueGen, State); - {error, Reason} -> - {error, Reason, State} + false -> + SW = os:timestamp(), + lager:info("Commencing listkeys request"), + case riakc_pb_socket:list_keys(State#state.pid, + State#state.bucket, + State#state.timeout_listkeys) of + {ok, Keys} -> + lager:info("listkeys request returned ~w keys" ++ + "in ~w seconds", + [length(Keys), + timer:now_diff(os:timestamp(), SW)/1000]), + {ok, State}; + {error, disconnected} -> + run(listkeys, _KeyGen, _ValueGen, State); + {error, Reason} -> + {error, Reason, State} + end end; run(search, _KeyGen, _ValueGen, #state{search_queries=SearchQs}=State) -> [{Index, Query, Options}|_] = SearchQs, From 765fcd18e02c80773cb242eb63a48c4dc53833a0 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 27 Jul 2017 15:52:10 +0100 Subject: [PATCH 19/75] Add listkeys config Idea is to run a separate basho_bench process for testing list keys - that will pause between requests --- examples/riakc_pb.config | 2 +- examples/riakc_pb_listkeys.config | 44 +++++++++++++++++++++++++++++ src/basho_bench_driver_riakc_pb.erl | 44 ++++++++++++----------------- 3 files changed, 63 insertions(+), 27 deletions(-) create mode 100644 examples/riakc_pb_listkeys.config diff --git a/examples/riakc_pb.config b/examples/riakc_pb.config index 552105000..9d43b659f 100644 --- a/examples/riakc_pb.config +++ b/examples/riakc_pb.config @@ -24,7 +24,7 @@ {riakc_pb_replies, 1}. %%% {operations, [{get, 1}]}. -{operations, [{get, 50000}, {update, 10000}, {listkeys, 1}]}. +{operations, [{get, 5}, {update, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. diff --git a/examples/riakc_pb_listkeys.config b/examples/riakc_pb_listkeys.config new file mode 100644 index 000000000..89b22ff89 --- /dev/null +++ b/examples/riakc_pb_listkeys.config @@ -0,0 +1,44 @@ +{mode, max}. + +{duration, 300}. +{report_interval, 300}. + +{concurrent, 1}. + +{driver, basho_bench_driver_riakc_pb}. + +{key_generator, + {concat_binary, + {base64, + {int_to_bin_bigendian, + {pareto_int, 200000000} + } + }, + <<>>} +}. + +{value_generator, {semi_compressible, 4000, 8000}}. + +{riakc_pb_ips, [{127,0,0,1}]}. + +{riakc_pb_replies, 1}. + +%%% {operations, [{get, 1}]}. +{operations, [{pause_minute, 4}, {listkeys, 1}]}. + +%% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). +%% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. +{pb_connect_options, [{auto_reconnect, true}]}. + +%% Overrides for the PB client's default 60 second timeout, on a +%% per-type-of-operation basis. All timeout units are specified in +%% milliseconds. The pb_timeout_general config item provides a +%% default timeout if the read/write/listkeys/mapreduce timeout is not +%% specified. + +{pb_timeout_general, 30000}. +{pb_timeout_read, 10000}. +{pb_timeout_write, 10000}. +{pb_timeout_listkeys, 3600000}. +%% The general timeout will be used because this specific item is commented: +%% {pb_timeout_mapreduce, 50000}. diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index 6e1c1f0fb..7f3f41fae 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -48,8 +48,7 @@ timeout_listkeys, timeout_mapreduce, twoi_qcount = 0 :: integer(), - twoi_rcount = 0 :: integer(), - listkeys_prob :: float() + twoi_rcount = 0 :: integer() }). -define(TIMEOUT_GENERAL, 62*1000). % Riak PB default + 2 sec @@ -83,7 +82,6 @@ {76, "OX"}]). -define(DATETIME_FORMAT, "~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w"). -define(DATE_FORMAT, "~b-~2..0b-~2..0b"). --define(LISTKEYS_PROBABILITY, 0.001). %% ==================================================================== %% API @@ -140,7 +138,6 @@ new(Id) -> start_time = os:timestamp(), keylist_length = KeylistLength, preloaded_keys = PreloadedKeys, - listkeys_prob = ?LISTKEYS_PROBABILITY, timeout_general = get_timeout_general(), timeout_read = get_timeout(pb_timeout_read), timeout_write = get_timeout(pb_timeout_write), @@ -486,30 +483,25 @@ run(delete, KeyGen, _ValueGen, State) -> {error, Reason, State} end; run(listkeys, _KeyGen, _ValueGen, State) -> - case random:uniform() > State#state.listkeys_prob of - true -> - % Skip the listkeys - % Note that we cannot use the stats from listkeys, as most of - % them are now null operations + SW = os:timestamp(), + lager:info("Commencing listkeys request"), + case riakc_pb_socket:list_keys(State#state.pid, + State#state.bucket, + State#state.timeout_listkeys) of + {ok, Keys} -> + lager:info("listkeys request returned ~w keys" ++ + "in ~w seconds", + [length(Keys), + timer:now_diff(os:timestamp(), SW)/1000]), {ok, State}; - false -> - SW = os:timestamp(), - lager:info("Commencing listkeys request"), - case riakc_pb_socket:list_keys(State#state.pid, - State#state.bucket, - State#state.timeout_listkeys) of - {ok, Keys} -> - lager:info("listkeys request returned ~w keys" ++ - "in ~w seconds", - [length(Keys), - timer:now_diff(os:timestamp(), SW)/1000]), - {ok, State}; - {error, disconnected} -> - run(listkeys, _KeyGen, _ValueGen, State); - {error, Reason} -> - {error, Reason, State} - end + {error, disconnected} -> + run(listkeys, _KeyGen, _ValueGen, State); + {error, Reason} -> + {error, Reason, State} end; +run(pause_minute, _KeyGen, _ValueGen, State) -> + timer:sleep(60), + {ok, State}; run(search, _KeyGen, _ValueGen, #state{search_queries=SearchQs}=State) -> [{Index, Query, Options}|_] = SearchQs, From ee6eafa7041f8d6c707f2cb7b176b402253f5edc Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 27 Jul 2017 15:57:41 +0100 Subject: [PATCH 20/75] Ooops ... milliseconds not seconds --- src/basho_bench_driver_riakc_pb.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index 7f3f41fae..b1cfc4064 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -500,7 +500,7 @@ run(listkeys, _KeyGen, _ValueGen, State) -> {error, Reason, State} end; run(pause_minute, _KeyGen, _ValueGen, State) -> - timer:sleep(60), + timer:sleep(60000), {ok, State}; run(search, _KeyGen, _ValueGen, #state{search_queries=SearchQs}=State) -> [{Index, Query, Options}|_] = SearchQs, From bf2e73bcafbafe4905db706b5a6e22e0c6bdb51a Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 27 Jul 2017 16:17:56 +0100 Subject: [PATCH 21/75] Correct log unit to seconds not ms For listkeys --- src/basho_bench_driver_riakc_pb.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index b1cfc4064..d82ed1a2c 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -492,7 +492,7 @@ run(listkeys, _KeyGen, _ValueGen, State) -> lager:info("listkeys request returned ~w keys" ++ "in ~w seconds", [length(Keys), - timer:now_diff(os:timestamp(), SW)/1000]), + timer:now_diff(os:timestamp(), SW)/1000000]), {ok, State}; {error, disconnected} -> run(listkeys, _KeyGen, _ValueGen, State); From 7d9e8ee2d5e935745ef433b01264a3745be4cb35 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 27 Jul 2017 16:19:17 +0100 Subject: [PATCH 22/75] Log typo --- src/basho_bench_driver_riakc_pb.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index d82ed1a2c..c92fb2461 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -490,7 +490,7 @@ run(listkeys, _KeyGen, _ValueGen, State) -> State#state.timeout_listkeys) of {ok, Keys} -> lager:info("listkeys request returned ~w keys" ++ - "in ~w seconds", + " in ~w seconds", [length(Keys), timer:now_diff(os:timestamp(), SW)/1000000]), {ok, State}; From 0c8b111e1158e9dd340c04205e6e7ebd1f23df0b Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 27 Jul 2017 17:13:51 +0100 Subject: [PATCH 23/75] Add support for a singleton listkeys worker Only one of the workers will run listkeys --- src/basho_bench_driver_riakc_pb.erl | 44 +++++++++++++++++------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index c92fb2461..d4e201172 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -48,7 +48,9 @@ timeout_listkeys, timeout_mapreduce, twoi_qcount = 0 :: integer(), - twoi_rcount = 0 :: integer() + twoi_rcount = 0 :: integer(), + nominated_id = false ::boolean() + % ID 1 is nominated to do special work }). -define(TIMEOUT_GENERAL, 62*1000). % Riak PB default + 2 sec @@ -123,7 +125,7 @@ new(Id) -> ?INFO("Using target ~p:~p for worker ~p\n", [TargetIp, TargetPort, Id]), case riakc_pb_socket:start_link(TargetIp, TargetPort, get_connect_options()) of {ok, Pid} -> - random:seed(), + NominatedID = Id == 1, {ok, #state { pid = Pid, bucket = Bucket, r = R, @@ -142,7 +144,8 @@ new(Id) -> timeout_read = get_timeout(pb_timeout_read), timeout_write = get_timeout(pb_timeout_write), timeout_listkeys = get_timeout(pb_timeout_listkeys), - timeout_mapreduce = get_timeout(pb_timeout_mapreduce) + timeout_mapreduce = get_timeout(pb_timeout_mapreduce), + nominated_id = NominatedID }}; {error, Reason2} -> ?FAIL_MSG("Failed to connect riakc_pb_socket to ~p:~p: ~p\n", @@ -483,21 +486,26 @@ run(delete, KeyGen, _ValueGen, State) -> {error, Reason, State} end; run(listkeys, _KeyGen, _ValueGen, State) -> - SW = os:timestamp(), - lager:info("Commencing listkeys request"), - case riakc_pb_socket:list_keys(State#state.pid, - State#state.bucket, - State#state.timeout_listkeys) of - {ok, Keys} -> - lager:info("listkeys request returned ~w keys" ++ - " in ~w seconds", - [length(Keys), - timer:now_diff(os:timestamp(), SW)/1000000]), - {ok, State}; - {error, disconnected} -> - run(listkeys, _KeyGen, _ValueGen, State); - {error, Reason} -> - {error, Reason, State} + case State#state.nominated_id of + true -> + SW = os:timestamp(), + lager:info("Commencing listkeys request"), + case riakc_pb_socket:list_keys(State#state.pid, + State#state.bucket, + State#state.timeout_listkeys) of + {ok, Keys} -> + lager:info("listkeys request returned ~w keys" ++ + " in ~w seconds", + [length(Keys), + timer:now_diff(os:timestamp(), SW)/1000000]), + {ok, State}; + {error, disconnected} -> + run(listkeys, _KeyGen, _ValueGen, State); + {error, Reason} -> + {error, Reason, State} + end; + false -> + {ok, State} end; run(pause_minute, _KeyGen, _ValueGen, State) -> timer:sleep(60000), From 75c826f6ef5efd0c50501501117e8ea6c859d80b Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sun, 30 Jul 2017 10:08:21 +0100 Subject: [PATCH 24/75] Attempt to make listkeys async Difficult to be sure that behaviour seen in test is as a result of feedback loop if listkeys takes longer (i.e. less requests are sent), rather than the actual cluster reacting to the ongoing listkeys operation. So now try and make this listkeys request async (but still ensure only one is run at a time) --- src/basho_bench_driver_riakc_pb.erl | 64 +++++++++++++++++++---------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index d4e201172..70f993002 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -26,6 +26,8 @@ mapred_valgen/2, mapred_ordered_valgen/1]). +-export([run_listkeys/1]). + -include("basho_bench.hrl"). -record(state, { pid, @@ -49,8 +51,11 @@ timeout_mapreduce, twoi_qcount = 0 :: integer(), twoi_rcount = 0 :: integer(), - nominated_id = false ::boolean() + nominated_id = false ::boolean(), % ID 1 is nominated to do special work + singleton_targets :: list(), + % List of targets to be used for singleton async pid + singleton_pid :: pid() | undefined }). -define(TIMEOUT_GENERAL, 62*1000). % Riak PB default + 2 sec @@ -145,7 +150,8 @@ new(Id) -> timeout_write = get_timeout(pb_timeout_write), timeout_listkeys = get_timeout(pb_timeout_listkeys), timeout_mapreduce = get_timeout(pb_timeout_mapreduce), - nominated_id = NominatedID + nominated_id = NominatedID, + singleton_targets = Targets }}; {error, Reason2} -> ?FAIL_MSG("Failed to connect riakc_pb_socket to ~p:~p: ~p\n", @@ -486,25 +492,15 @@ run(delete, KeyGen, _ValueGen, State) -> {error, Reason, State} end; run(listkeys, _KeyGen, _ValueGen, State) -> - case State#state.nominated_id of - true -> - SW = os:timestamp(), - lager:info("Commencing listkeys request"), - case riakc_pb_socket:list_keys(State#state.pid, - State#state.bucket, - State#state.timeout_listkeys) of - {ok, Keys} -> - lager:info("listkeys request returned ~w keys" ++ - " in ~w seconds", - [length(Keys), - timer:now_diff(os:timestamp(), SW)/1000000]), - {ok, State}; - {error, disconnected} -> - run(listkeys, _KeyGen, _ValueGen, State); - {error, Reason} -> - {error, Reason, State} - end; - false -> + case {State#state.nominated_id, + is_process_alive(State#state.singleton_pid)} of + {true, true} -> + lager:info("Skipping listkeys for overlap"), + {ok, State}; + {true, false} -> + {ok, Pid} = spawn(?MODULE, run_listkeys, State), + {ok, State#state{singleton_pid = Pid}}; + _ -> {ok, State} end; run(pause_minute, _KeyGen, _ValueGen, State) -> @@ -790,3 +786,29 @@ record_2i_results(Results, State) -> false -> {ok, State#state{twoi_qcount = QCount, twoi_rcount = RCount}} end. + +run_listkeys(State) -> + SW = os:timestamp(), + lager:info("Commencing listkeys request"), + + Targets = State#state.singleton_targets, + {TargetIp, TargetPort} = lists:nth(random:uniform(length(Targets)+1), + Targets), + ?INFO("Using target ~p:~p for new singleton asyncworker\n", + [TargetIp, TargetPort]), + {ok, Pid} = riakc_pb_socket:start_link(TargetIp, + TargetPort, + get_connect_options()), + case riakc_pb_socket:list_keys(Pid, + State#state.bucket, + State#state.timeout_listkeys) of + {ok, Keys} -> + lager:info("listkeys request returned ~w keys" ++ + " in ~w seconds", + [length(Keys), + timer:now_diff(os:timestamp(), SW)/1000000]), + ok; + {error, Reason} -> + lager:info("listkeys failed due to reason ~w", [Reason]), + ok + end. From c50aea6602b126e1e693c8c271eb569b27a81fef Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sun, 30 Jul 2017 10:15:53 +0100 Subject: [PATCH 25/75] Handle undefined pid When checking is_process_alive --- src/basho_bench_driver_riakc_pb.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index 70f993002..4d3df4832 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -492,8 +492,14 @@ run(delete, KeyGen, _ValueGen, State) -> {error, Reason, State} end; run(listkeys, _KeyGen, _ValueGen, State) -> - case {State#state.nominated_id, - is_process_alive(State#state.singleton_pid)} of + IsAlive = + case State#state.singleton_pid of + undefined -> + false; + LastPid -> + is_process_alive(LastPid) + end, + case {State#state.nominated_id, IsAlive} of {true, true} -> lager:info("Skipping listkeys for overlap"), {ok, State}; From f6a6e89e21786192c278aae17b80cd2aa99cd2cf Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sun, 30 Jul 2017 10:31:37 +0100 Subject: [PATCH 26/75] Make Args list --- src/basho_bench_driver_riakc_pb.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index 4d3df4832..c93ac5b64 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -504,10 +504,10 @@ run(listkeys, _KeyGen, _ValueGen, State) -> lager:info("Skipping listkeys for overlap"), {ok, State}; {true, false} -> - {ok, Pid} = spawn(?MODULE, run_listkeys, State), + {ok, Pid} = spawn(?MODULE, run_listkeys, [State]), {ok, State#state{singleton_pid = Pid}}; _ -> - {ok, State} + {ok, State} end; run(pause_minute, _KeyGen, _ValueGen, State) -> timer:sleep(60000), From ceb61272f068bbdf0d998179e0fb1993052812cd Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sun, 30 Jul 2017 10:37:20 +0100 Subject: [PATCH 27/75] Correct return from spawn --- src/basho_bench_driver_riakc_pb.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_riakc_pb.erl b/src/basho_bench_driver_riakc_pb.erl index c93ac5b64..96bfb3fc0 100644 --- a/src/basho_bench_driver_riakc_pb.erl +++ b/src/basho_bench_driver_riakc_pb.erl @@ -504,7 +504,7 @@ run(listkeys, _KeyGen, _ValueGen, State) -> lager:info("Skipping listkeys for overlap"), {ok, State}; {true, false} -> - {ok, Pid} = spawn(?MODULE, run_listkeys, [State]), + Pid = spawn(?MODULE, run_listkeys, [State]), {ok, State#state{singleton_pid = Pid}}; _ -> {ok, State} From fa47990657037fd7a6c77eff57b78aaa9dc5d9ca Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 16 Aug 2017 13:19:35 +0100 Subject: [PATCH 28/75] Add multiplier Allows for the frequency of particularly large objects to be enhanced --- examples/riakc_nhs.config | 2 +- examples/riakc_pb.config | 2 +- src/basho_bench_valgen.erl | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index f6e429c2a..9b3c23cd5 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -9,7 +9,7 @@ {key_generator, {pareto_int, 100000000}}. -{value_generator, {semi_compressible, 4000, 4000}}. +{value_generator, {semi_compressible, 4000, 4000, 10, 0.1}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. diff --git a/examples/riakc_pb.config b/examples/riakc_pb.config index 9d43b659f..f4673821e 100644 --- a/examples/riakc_pb.config +++ b/examples/riakc_pb.config @@ -17,7 +17,7 @@ <<>>} }. -{value_generator, {semi_compressible, 4000, 8000}}. +{value_generator, {semi_compressible, 4000, 4000, 10, 0.001}}. {riakc_pb_ips, [{127,0,0,1}]}. diff --git a/src/basho_bench_valgen.erl b/src/basho_bench_valgen.erl index 1a8891399..ed4c22e7a 100644 --- a/src/basho_bench_valgen.erl +++ b/src/basho_bench_valgen.erl @@ -64,12 +64,20 @@ new({uniform_int, MaxVal}, _Id) new({uniform_int, MinVal, MaxVal}, _Id) when is_integer(MinVal), is_integer(MaxVal), MaxVal > MinVal -> fun() -> random:uniform(MinVal, MaxVal) end; -new({semi_compressible, MinSize, Mean}, Id) +new({semi_compressible, MinSize, Mean, XLMult, XLProb}, Id) when is_integer(MinSize), MinSize >= 0, is_number(Mean), Mean > 0 -> Source = init_altsource(Id), fun() -> + R = random:uniform(), + {ModMin, ModMean} = + case R < XLProb of + true -> + {XLMult * MinSize, XLMult * Mean}; + false -> + {MinSize, Mean} + end, data_block(Source, - MinSize + trunc(basho_bench_stats:exponential(1 / Mean))) + ModMin + trunc(basho_bench_stats:exponential(1 / ModMean))) end; new(Other, _Id) -> ?FAIL_MSG("Invalid value generator requested: ~p\n", [Other]). From 3142acb7d3153c8989d0dab32658d5c2330fb822 Mon Sep 17 00:00:00 2001 From: Ramen Sen Date: Wed, 4 Oct 2017 10:07:42 +0000 Subject: [PATCH 29/75] Fixes to get nhs driver working --- examples/riakc_nhs.config | 1 - src/basho_bench_driver_nhs.erl | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 9b3c23cd5..2721dc754 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -17,7 +17,6 @@ {riakc_pb_replies, 1}. {operations, [{get_pb, 200}, {update_with2i, 50}, {put_unique, 10}, - {postcodequery_http, 3}, {dobquery_http, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 487489a7d..b13d1a96f 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -136,11 +136,11 @@ run(update_with2i, KeyGen, ValueGen, State) -> {ok, Robj} -> Robj; {error, notfound} -> - riak_object:new(Bucket, Key) + riakc_obj:new(Bucket, to_binary(Key)) end, MD0 = riakc_obj:get_update_metadata(Robj0), - MD1 = riakc_obj:clear_scondary_indexes(MD0), + MD1 = riakc_obj:clear_secondary_indexes(MD0), MD2 = riakc_obj:set_secondary_index(MD1, generate_binary_indexes()), Robj1 = riakc_obj:update_value(Robj0, Value), Robj2 = riakc_obj:update_metadata(Robj1, MD2), @@ -160,7 +160,7 @@ run(put_unique, _KeyGen, _ValueGen, State) -> Key = generate_uniquekey(), Value = non_compressible_value(6000), - Robj0 = riak_object:new(Bucket, Key), + Robj0 = riakc_obj:new(Bucket, to_binary(Key)), MD1 = riakc_obj:get_update_metadata(Robj0), MD2 = riakc_obj:set_secondary_index(MD1, generate_binary_indexes()), Robj1 = riakc_obj:update_value(Robj0, Value), @@ -176,12 +176,12 @@ run(put_unique, _KeyGen, _ValueGen, State) -> %% Query results via the HTTP interface. run(postcodequery_http, _KeyGen, _ValueGen, State) -> - Host = State#state.http_host, + Host = inet_parse:ntoa(State#state.http_host), Port = State#state.http_port, Bucket = State#state.recordBucket, L = length(?POSTCODE_AREAS), - Area = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), + {_, Area} = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), District = Area ++ integer_to_list(random:uniform(26)), StartKey = District ++ "|" ++ "a", EndKey = District ++ "|" ++ "b", @@ -191,7 +191,7 @@ run(postcodequery_http, _KeyGen, _ValueGen, State) -> case json_get(URL, State) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), - io:format("PostC query results of length ~w~n", length(Results)), + %% io:format("PostC query results of length ~w~n", [length(Results)]), {ok, State}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", @@ -201,7 +201,7 @@ run(postcodequery_http, _KeyGen, _ValueGen, State) -> %% Query results via the HTTP interface. run(dobquery_http, _KeyGen, _ValueGen, State) -> - Host = State#state.http_host, + Host = inet_parse:ntoa(State#state.http_host), Port = State#state.http_port, Bucket = State#state.recordBucket, @@ -216,7 +216,7 @@ run(dobquery_http, _KeyGen, _ValueGen, State) -> case json_get(URL, State) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), - io:format("DoB query results of length ~w~n", length(Results)), + %% io:format("DoB query results of length ~w~n", [length(Results)]), {ok, State}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", @@ -271,7 +271,7 @@ postcode_index() -> NotVeryNameLikeThing = base64:encode_to_string(crypto:rand_bytes(4)), lists:map(fun(_X) -> L = length(?POSTCODE_AREAS), - Area = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), + {_, Area} = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), District = Area ++ integer_to_list(random:uniform(26)), F = District ++ "|" ++ NotVeryNameLikeThing, list_to_binary(F) end, From 395893ca81225d56681f685086ea62177570191e Mon Sep 17 00:00:00 2001 From: Ramen Sen Date: Wed, 4 Oct 2017 10:35:42 +0000 Subject: [PATCH 30/75] Changed operations to reflect actual test, and re-added io:format statements for monitoring. --- examples/riakc_nhs.config | 3 ++- src/basho_bench_driver_nhs.erl | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 2721dc754..89248b724 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -16,7 +16,8 @@ {riakc_pb_replies, 1}. -{operations, [{get_pb, 200}, {update_with2i, 50}, {put_unique, 10}, +{operations, [{get_pb, 400}, {update_with2i, 100}, {put_unique, 20}, + {postcodequery_http, 1}, {dobquery_http, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index b13d1a96f..9197092dd 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -191,7 +191,7 @@ run(postcodequery_http, _KeyGen, _ValueGen, State) -> case json_get(URL, State) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), - %% io:format("PostC query results of length ~w~n", [length(Results)]), + io:format("PostC query results of length ~w~n", [length(Results)]), {ok, State}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", @@ -216,7 +216,7 @@ run(dobquery_http, _KeyGen, _ValueGen, State) -> case json_get(URL, State) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), - %% io:format("DoB query results of length ~w~n", [length(Results)]), + io:format("DoB query results of length ~w~n", [length(Results)]), {ok, State}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", From f0b7e6c1e700846fdf2bdd898362b0bcc8b483a1 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 4 Oct 2017 11:58:20 +0100 Subject: [PATCH 31/75] Change logging of average query response size Also add tag to key correctly --- src/basho_bench_driver_nhs.erl | 41 ++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 9197092dd..388103098 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -33,7 +33,11 @@ recordBucket, documentBucket, pb_timeout, - http_timeout + http_timeout, + postcodeq_count = 0 :: integer(), + postcodeq_sum = 0 :: integer(), + dobq_count = 0 :: integer(), + dobq_sum = 0 :: integer() }). -define(POSTCODE_AREAS, @@ -191,8 +195,20 @@ run(postcodequery_http, _KeyGen, _ValueGen, State) -> case json_get(URL, State) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), - io:format("PostC query results of length ~w~n", [length(Results)]), - {ok, State}; + {C0, S0} = + case State#state.postcodeq_count div 1000 of + 0 -> + Avg = + State#state.postcodeq_sum + div State#state.postcodeq_count, + lager:info("Average postcode query result size of ~w", + [Avg]), + {1, length(Results)}; + _ -> + {State#state.postcodeq_count + 1, + State#state.postcodeq_sum + length(Results)} + end, + {ok, State#state{postcodeq_count = C0, postcodeq_sum = S0}}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", [?MODULE, ?LINE, Reason]), @@ -216,8 +232,19 @@ run(dobquery_http, _KeyGen, _ValueGen, State) -> case json_get(URL, State) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), - io:format("DoB query results of length ~w~n", [length(Results)]), - {ok, State}; + {C0, S0} = + case State#state.dobq_count div 1000 of + 0 -> + Avg = + State#state.dobq_sum div State#state.dobq_count, + lager:info("Average dob query result size of ~w", + [Avg]), + {1, length(Results)}; + _ -> + {State#state.dobq_count + 1, + State#state.dobq_sum + length(Results)} + end, + {ok, State#state{dobq_count = C0, dobq_sum = S0}}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", [?MODULE, ?LINE, Reason]), @@ -298,8 +325,8 @@ generate_uniquekey() -> {Hr, Min, Sec}} = calendar:now_to_datetime(os:timestamp()), F = lists:flatten(io_lib:format(?DATETIME_FORMAT, [Year, Month, Day, Hr, Min, Sec])), - F ++ [base64:encode_to_string(crypto:rand_bytes(4))], - list_to_binary(F). + F0 = F ++ [base64:encode_to_string(crypto:rand_bytes(4))], + list_to_binary(F0). non_compressible_value(Size) -> crypto:rand_bytes(Size). From d1ad2c4057dfa1c45cc9fc41bccc4a4917435c69 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 4 Oct 2017 15:11:23 +0100 Subject: [PATCH 32/75] Divide by 0! Not a good thing --- src/basho_bench_driver_nhs.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 388103098..5a2110bf5 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -197,7 +197,7 @@ run(postcodequery_http, _KeyGen, _ValueGen, State) -> Results = proplists:get_value(<<"keys">>, Proplist), {C0, S0} = case State#state.postcodeq_count div 1000 of - 0 -> + 1 -> Avg = State#state.postcodeq_sum div State#state.postcodeq_count, @@ -234,7 +234,7 @@ run(dobquery_http, _KeyGen, _ValueGen, State) -> Results = proplists:get_value(<<"keys">>, Proplist), {C0, S0} = case State#state.dobq_count div 1000 of - 0 -> + 1 -> Avg = State#state.dobq_sum div State#state.dobq_count, lager:info("Average dob query result size of ~w", From 78e9939a915b33c6dbb28ba8ff2b28d700466017 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 4 Oct 2017 17:41:58 +0100 Subject: [PATCH 33/75] Fix regular expression --- src/basho_bench_driver_nhs.erl | 58 ++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 5a2110bf5..6fc57c40a 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -37,9 +37,12 @@ postcodeq_count = 0 :: integer(), postcodeq_sum = 0 :: integer(), dobq_count = 0 :: integer(), - dobq_sum = 0 :: integer() + dobq_sum = 0 :: integer(), + query_logfreq :: integer() }). +-define(QUERYLOG_FREQ, 1000). + -define(POSTCODE_AREAS, [{1, "AB"}, {2, "AL"}, {3, "B"}, {4, "BA"}, {5, "BB"}, {6, "BD"}, {7, "BH"}, {8, "BL"}, {9, "BN"}, {10, "BR"}, @@ -58,7 +61,7 @@ {71, "MM"}, {72, "NP"}, {73, "NR"}, {74, "NW"}, {75, "OL"}, {76, "OX"}]). -define(DATETIME_FORMAT, "~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w"). --define(DATE_FORMAT, "~b-~2..0b-~2..0b"). +-define(DATE_FORMAT, "~b~2..0b~2..0b"). %% ==================================================================== %% API @@ -108,7 +111,8 @@ new(Id) -> recordBucket = <<"domainRecord">>, documentBucket = <<"domainDocument">>, pb_timeout = PBTimeout, - http_timeout = HTTPTimeout}}; + http_timeout = HTTPTimeout, + query_logfreq = random:uniform(?QUERYLOG_FREQ)}}; {error, Reason2} -> ?FAIL_MSG("Failed to connect riakc_pb_socket to ~p port ~p: ~p\n", [PBTargetIp, PBTargetPort, Reason2]) @@ -188,27 +192,26 @@ run(postcodequery_http, _KeyGen, _ValueGen, State) -> {_, Area} = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), District = Area ++ integer_to_list(random:uniform(26)), StartKey = District ++ "|" ++ "a", - EndKey = District ++ "|" ++ "b", + EndKey = District ++ "|" ++ "p", URL = io_lib:format("http://~s:~p/buckets/~s/index/postcode_bin/~s/~s", [Host, Port, Bucket, StartKey, EndKey]), case json_get(URL, State) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), - {C0, S0} = - case State#state.postcodeq_count div 1000 of - 1 -> - Avg = - State#state.postcodeq_sum - div State#state.postcodeq_count, - lager:info("Average postcode query result size of ~w", + C0 = State#state.postcodeq_count, + S0 = State#state.postcodeq_sum, + {C1, S1} = + case {C0, C0 rem State#state.query_logfreq} of + {C0, 0} when C0 > 0 -> + Avg = float_to_list(S0 / C0, [{decimals, 3}]), + lager:info("Average postcode query result size of ~s", [Avg]), {1, length(Results)}; _ -> - {State#state.postcodeq_count + 1, - State#state.postcodeq_sum + length(Results)} + {C0 + 1, S0 + length(Results)} end, - {ok, State#state{postcodeq_count = C0, postcodeq_sum = S0}}; + {ok, State#state{postcodeq_count = C1, postcodeq_sum = S1}}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", [?MODULE, ?LINE, Reason]), @@ -225,26 +228,28 @@ run(dobquery_http, _KeyGen, _ValueGen, State) -> DoBStart = integer_to_list(RandYear) ++ "0101", DoBEnd = integer_to_list(RandYear) ++ "0110", - URLSrc = "http://~s:~p/buckets/~s/index/postcode_bin/~s/~s?term_regex=~s", + URLSrc = + "http://~s:~p/buckets/~s/index/dateofbirth_bin/~s/~s?term_regex=~s", + RE= "[0-9]{8}.[a-d]", URL = io_lib:format(URLSrc, - [Host, Port, Bucket, DoBStart, DoBEnd, "[0-9]{8}\|a"]), + [Host, Port, Bucket, DoBStart, DoBEnd, RE]), case json_get(URL, State) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), - {C0, S0} = - case State#state.dobq_count div 1000 of - 1 -> - Avg = - State#state.dobq_sum div State#state.dobq_count, - lager:info("Average dob query result size of ~w", + C0 = State#state.dobq_count, + S0 = State#state.dobq_sum, + {C1, S1} = + case {C0, C0 rem State#state.query_logfreq} of + {C0, 0} when C0 > 0 -> + Avg = float_to_list(S0 / C0, [{decimals, 3}]), + lager:info("Average dob query result size of ~s", [Avg]), {1, length(Results)}; _ -> - {State#state.dobq_count + 1, - State#state.dobq_sum + length(Results)} + {C0 + 1, S0 + length(Results)} end, - {ok, State#state{dobq_count = C0, dobq_sum = S0}}; + {ok, State#state{dobq_count = C1, dobq_sum = S1}}; {error, Reason} -> io:format("[~s:~p] ERROR - Reason: ~p~n", [?MODULE, ?LINE, Reason]), @@ -308,8 +313,7 @@ dateofbirth_index() -> Delta = random:uniform(2500000000), {{Y, M, D}, _} = calendar:gregorian_seconds_to_datetime(Delta + 61000000000), - F = lists:flatten(io_lib:format(?DATE_FORMAT, [Y, M, D])) ++ "|" ++ - base64:encode_to_string(crypto:rand_bytes(4)), + F = lists:flatten(io_lib:format(?DATE_FORMAT, [Y, M, D])) ++ "|" ++ base64:encode_to_string(crypto:rand_bytes(4)), [list_to_binary(F)]. lastmodified_index() -> From 31246f8cd01cf0b242256ef44f84b9d6e9b3b992 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 4 Oct 2017 17:42:25 +0100 Subject: [PATCH 34/75] Slim query results a bit --- src/basho_bench_driver_nhs.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 6fc57c40a..d69f940ec 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -192,7 +192,7 @@ run(postcodequery_http, _KeyGen, _ValueGen, State) -> {_, Area} = lists:keyfind(random:uniform(L), 1, ?POSTCODE_AREAS), District = Area ++ integer_to_list(random:uniform(26)), StartKey = District ++ "|" ++ "a", - EndKey = District ++ "|" ++ "p", + EndKey = District ++ "|" ++ "h", URL = io_lib:format("http://~s:~p/buckets/~s/index/postcode_bin/~s/~s", [Host, Port, Bucket, StartKey, EndKey]), From bc51325ba22685c14c948cf93ce0259d7ac8a5e4 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 5 Oct 2017 10:03:49 +0100 Subject: [PATCH 35/75] Add draft aae query support --- src/basho_bench_driver_nhs.erl | 91 ++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index d69f940ec..88ba19841 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -24,21 +24,26 @@ -export([new/1, run/4]). +-export([run_aaequery/1]). + -include("basho_bench.hrl"). -record(state, { - pb_pid, - http_host, - http_port, - recordBucket, - documentBucket, - pb_timeout, - http_timeout, - postcodeq_count = 0 :: integer(), - postcodeq_sum = 0 :: integer(), - dobq_count = 0 :: integer(), - dobq_sum = 0 :: integer(), - query_logfreq :: integer() + pb_pid, + http_host, + http_port, + recordBucket, + documentBucket, + pb_timeout, + http_timeout, + postcodeq_count = 0 :: integer(), + postcodeq_sum = 0 :: integer(), + dobq_count = 0 :: integer(), + dobq_sum = 0 :: integer(), + query_logfreq :: integer(), + nominated_id :: boolean(), + % ID 1 is nominated to do special work + singleton_pid :: pid() | undefined }). -define(QUERYLOG_FREQ, 1000). @@ -104,6 +109,7 @@ new(Id) -> case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of {ok, Pid} -> + NominatedID = Id == 1, {ok, #state { pb_pid = Pid, http_host = HTTPTargetIp, @@ -112,7 +118,8 @@ new(Id) -> documentBucket = <<"domainDocument">>, pb_timeout = PBTimeout, http_timeout = HTTPTimeout, - query_logfreq = random:uniform(?QUERYLOG_FREQ)}}; + query_logfreq = random:uniform(?QUERYLOG_FREQ), + nominated_id = NominatedID}}; {error, Reason2} -> ?FAIL_MSG("Failed to connect riakc_pb_socket to ~p port ~p: ~p\n", [PBTargetIp, PBTargetPort, Reason2]) @@ -230,7 +237,7 @@ run(dobquery_http, _KeyGen, _ValueGen, State) -> URLSrc = "http://~s:~p/buckets/~s/index/dateofbirth_bin/~s/~s?term_regex=~s", - RE= "[0-9]{8}.[a-d]", + RE= "[0-9]{8}...[a-d]", URL = io_lib:format(URLSrc, [Host, Port, Bucket, DoBStart, DoBEnd, RE]), @@ -256,6 +263,25 @@ run(dobquery_http, _KeyGen, _ValueGen, State) -> {error, Reason, State} end; +run(aae_query, _KeyGen, _ValueGen, State) -> + IsAlive = + case State#state.singleton_pid of + undefined -> + false; + LastPid -> + is_process_alive(LastPid) + end, + case {State#state.nominated_id, IsAlive} of + {true, true} -> + lager:info("Skipping listkeys for overlap"), + {ok, State}; + {true, false} -> + Pid = spawn(?MODULE, run_aaequery, [State]), + {ok, State#state{singleton_pid = Pid}}; + _ -> + {ok, State} + end; + run(Other, _, _, _) -> throw({unknown_operation, Other}). @@ -290,6 +316,43 @@ ensure_module(Module) -> ok end. + +%% ==================================================================== +%% Spawned Runners +%% ==================================================================== + + +run_aaequery(State) -> + SW = os:timestamp(), + lager:info("Commencing aaequery request"), + + Host = inet_parse:ntoa(State#state.http_host), + Port = State#state.http_port, + Bucket = State#state.recordBucket, + + KeyStart = "0", + KeyEnd = "z", + + MapFoldMod = "riak_kv_tictac_folder", + + URLSrc = + "http://~s:~p/buckets/~s/index/$key/~s/~s?mapfold=true&mapfoldmod=~s", + URL = io_lib:format(URLSrc, + [Host, Port, Bucket, KeyStart, KeyEnd, MapFoldMod]), + + case json_get(URL, State) of + {ok, {struct, _AAETree}} -> + lager:info("AAE query returned in ~w seconds", + [timer:now_diff(os:timestamp(), SW)/1000000]), + + {ok, State}; + {error, Reason} -> + io:format("[~s:~p] ERROR - Reason: ~p~n", + [?MODULE, ?LINE, Reason]), + {error, Reason, State} + end. + + %% ==================================================================== %% Index seeds %% ==================================================================== From 5f174d6310d1c66f8117395daa48a93e875a550f Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 5 Oct 2017 13:22:11 +0100 Subject: [PATCH 36/75] Change timeout for aae fold --- src/basho_bench_driver_nhs.erl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 88ba19841..92552d539 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -36,6 +36,7 @@ documentBucket, pb_timeout, http_timeout, + fold_timeout, postcodeq_count = 0 :: integer(), postcodeq_sum = 0 :: integer(), dobq_count = 0 :: integer(), @@ -88,6 +89,7 @@ new(Id) -> PBTimeout = basho_bench_config:get(pb_timeout_general, 30*1000), HTTPTimeout = basho_bench_config:get(http_timeout_general, 30*1000), + FoldTimeout = basho_bench_config:get(fold_timeout_general, 60*60*1000), %% Choose the target node using our ID as a modulus HTTPTargets = basho_bench_config:normalize_ips(HTTPIPs, HTTPPort), @@ -118,6 +120,7 @@ new(Id) -> documentBucket = <<"domainDocument">>, pb_timeout = PBTimeout, http_timeout = HTTPTimeout, + fold_timeout = FoldTimeout, query_logfreq = random:uniform(?QUERYLOG_FREQ), nominated_id = NominatedID}}; {error, Reason2} -> @@ -203,7 +206,7 @@ run(postcodequery_http, _KeyGen, _ValueGen, State) -> URL = io_lib:format("http://~s:~p/buckets/~s/index/postcode_bin/~s/~s", [Host, Port, Bucket, StartKey, EndKey]), - case json_get(URL, State) of + case json_get(URL, State#state.http_timeout) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), C0 = State#state.postcodeq_count, @@ -241,7 +244,7 @@ run(dobquery_http, _KeyGen, _ValueGen, State) -> URL = io_lib:format(URLSrc, [Host, Port, Bucket, DoBStart, DoBEnd, RE]), - case json_get(URL, State) of + case json_get(URL, State#state.http_timeout) of {ok, {struct, Proplist}} -> Results = proplists:get_value(<<"keys">>, Proplist), C0 = State#state.dobq_count, @@ -289,9 +292,10 @@ run(Other, _, _, _) -> %% Internal functions %% ==================================================================== -json_get(Url, State) -> - Response = ibrowse:send_req(lists:flatten(Url), [], get, - [], [], State#state.pb_timeout), + + +json_get(Url, Timeout) when is_integer(Timeout) -> + Response = ibrowse:send_req(lists:flatten(Url), [], get, [], [], Timeout), case Response of {ok, "200", _, Body} -> {ok, mochijson2:decode(Body)}; @@ -299,6 +303,7 @@ json_get(Url, State) -> {error, Other} end. + to_binary(B) when is_binary(B) -> B; to_binary(I) when is_integer(I) -> @@ -340,7 +345,7 @@ run_aaequery(State) -> URL = io_lib:format(URLSrc, [Host, Port, Bucket, KeyStart, KeyEnd, MapFoldMod]), - case json_get(URL, State) of + case json_get(URL, State#state.fold_timeout) of {ok, {struct, _AAETree}} -> lager:info("AAE query returned in ~w seconds", [timer:now_diff(os:timestamp(), SW)/1000000]), From c63c5d749b8ebd8a2e5b59c58c8b2e4fcfa19f57 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 5 Oct 2017 14:01:39 +0100 Subject: [PATCH 37/75] Split HTTP target for fold 2i queries were timing out whilst the fold was going on - queries being sent to the same connection? Separate folds out onto different HTTP target to avoid this --- src/basho_bench_driver_nhs.erl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 92552d539..cb9d69202 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -32,6 +32,8 @@ pb_pid, http_host, http_port, + fold_host, + fold_port, recordBucket, documentBucket, pb_timeout, @@ -96,6 +98,9 @@ new(Id) -> {HTTPTargetIp, HTTPTargetPort} = lists:nth((Id rem length(HTTPTargets) + 1), HTTPTargets), + {FoldTargetIp, + FoldTargetPort} = lists:nth((Id rem length(HTTPTargets) + 2), + HTTPTargets), ?INFO("Using http target ~p:~p for worker ~p\n", [HTTPTargetIp, HTTPTargetPort, Id]), @@ -116,6 +121,8 @@ new(Id) -> pb_pid = Pid, http_host = HTTPTargetIp, http_port = HTTPTargetPort, + fold_host = FoldTargetIp, % issues when long-lived fold + fold_port = FoldTargetport, % uses same connection as 2i query recordBucket = <<"domainRecord">>, documentBucket = <<"domainDocument">>, pb_timeout = PBTimeout, @@ -331,8 +338,8 @@ run_aaequery(State) -> SW = os:timestamp(), lager:info("Commencing aaequery request"), - Host = inet_parse:ntoa(State#state.http_host), - Port = State#state.http_port, + Host = inet_parse:ntoa(State#state.fold_host), + Port = State#state.fold_port, Bucket = State#state.recordBucket, KeyStart = "0", From 80c62571db983eb3bb0669795d13dcfaeac025b1 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 5 Oct 2017 14:30:25 +0100 Subject: [PATCH 38/75] Fix typo --- src/basho_bench_driver_nhs.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index cb9d69202..c7451742a 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -122,7 +122,7 @@ new(Id) -> http_host = HTTPTargetIp, http_port = HTTPTargetPort, fold_host = FoldTargetIp, % issues when long-lived fold - fold_port = FoldTargetport, % uses same connection as 2i query + fold_port = FoldTargetPort, % uses same connection as 2i query recordBucket = <<"domainRecord">>, documentBucket = <<"domainDocument">>, pb_timeout = PBTimeout, From e920a95202e0c3c9f5c9e9e9648bb1a11d170a2b Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 5 Oct 2017 15:25:36 +0100 Subject: [PATCH 39/75] Force fold onto separate HTTP target Means that 2i queries will not be evenly balanced --- src/basho_bench_driver_nhs.erl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index c7451742a..8fc644111 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -95,12 +95,10 @@ new(Id) -> %% Choose the target node using our ID as a modulus HTTPTargets = basho_bench_config:normalize_ips(HTTPIPs, HTTPPort), + [{FoldTargetIp, FoldTargetPort}|OtherHTTPTargets] = HTTPTargets, {HTTPTargetIp, - HTTPTargetPort} = lists:nth((Id rem length(HTTPTargets) + 1), - HTTPTargets), - {FoldTargetIp, - FoldTargetPort} = lists:nth((Id rem length(HTTPTargets) + 2), - HTTPTargets), + HTTPTargetPort} = lists:nth((Id rem length(OtherHTTPTargets) + 1), + OtherHTTPTargets), ?INFO("Using http target ~p:~p for worker ~p\n", [HTTPTargetIp, HTTPTargetPort, Id]), From 082a3217ab3450ae58080a1ee2a19361a6961f79 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 5 Oct 2017 15:32:53 +0100 Subject: [PATCH 40/75] Attempt to use ibrowse spawn RTFM - and ibrowse has a way of handling longer running requests by spawning them outside of the pool. Try using this. --- src/basho_bench_driver_nhs.erl | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 8fc644111..9fa0b4eb5 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -32,8 +32,6 @@ pb_pid, http_host, http_port, - fold_host, - fold_port, recordBucket, documentBucket, pb_timeout, @@ -95,10 +93,9 @@ new(Id) -> %% Choose the target node using our ID as a modulus HTTPTargets = basho_bench_config:normalize_ips(HTTPIPs, HTTPPort), - [{FoldTargetIp, FoldTargetPort}|OtherHTTPTargets] = HTTPTargets, {HTTPTargetIp, - HTTPTargetPort} = lists:nth((Id rem length(OtherHTTPTargets) + 1), - OtherHTTPTargets), + HTTPTargetPort} = lists:nth((Id rem length(HTTPTargets) + 1), + HTTPTargets), ?INFO("Using http target ~p:~p for worker ~p\n", [HTTPTargetIp, HTTPTargetPort, Id]), @@ -119,8 +116,6 @@ new(Id) -> pb_pid = Pid, http_host = HTTPTargetIp, http_port = HTTPTargetPort, - fold_host = FoldTargetIp, % issues when long-lived fold - fold_port = FoldTargetPort, % uses same connection as 2i query recordBucket = <<"domainRecord">>, documentBucket = <<"domainDocument">>, pb_timeout = PBTimeout, @@ -299,8 +294,19 @@ run(Other, _, _, _) -> -json_get(Url, Timeout) when is_integer(Timeout) -> - Response = ibrowse:send_req(lists:flatten(Url), [], get, [], [], Timeout), +json_get(Url, Timeout) -> + json_get(Url, Timeout, true). + +json_get(Url, Timeout, UsePool) -> + Target = lists:flatten(Url), + Response = + case UsePool of + true -> + ibrowse:send_req(Target, [], get, [], [], Timeout); + false -> + {ok, C} = ibrowse:spawn_worker_process(Target), + ibrowse:send_req(C, Target, [], get, [], [], Timeout) + end, case Response of {ok, "200", _, Body} -> {ok, mochijson2:decode(Body)}; @@ -336,8 +342,8 @@ run_aaequery(State) -> SW = os:timestamp(), lager:info("Commencing aaequery request"), - Host = inet_parse:ntoa(State#state.fold_host), - Port = State#state.fold_port, + Host = inet_parse:ntoa(State#state.http_host), + Port = State#state.http_port, Bucket = State#state.recordBucket, KeyStart = "0", @@ -350,7 +356,7 @@ run_aaequery(State) -> URL = io_lib:format(URLSrc, [Host, Port, Bucket, KeyStart, KeyEnd, MapFoldMod]), - case json_get(URL, State#state.fold_timeout) of + case json_get(URL, State#state.fold_timeout, false) of {ok, {struct, _AAETree}} -> lager:info("AAE query returned in ~w seconds", [timer:now_diff(os:timestamp(), SW)/1000000]), From 680398b99104767a69a1e4433420eca69824ed4b Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 5 Oct 2017 15:39:07 +0100 Subject: [PATCH 41/75] D'Oh RTFM again --- src/basho_bench_driver_nhs.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 9fa0b4eb5..5cf61ee27 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -305,7 +305,7 @@ json_get(Url, Timeout, UsePool) -> ibrowse:send_req(Target, [], get, [], [], Timeout); false -> {ok, C} = ibrowse:spawn_worker_process(Target), - ibrowse:send_req(C, Target, [], get, [], [], Timeout) + ibrowse:send_req_direct(C, Target, [], get, [], [], Timeout) end, case Response of {ok, "200", _, Body} -> From 82dd01c338d646eebe9d0495d1cc7d28847d79ca Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 5 Oct 2017 19:51:27 +0100 Subject: [PATCH 42/75] Add list keys support --- src/basho_bench_driver_nhs.erl | 49 ++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 5cf61ee27..d71c77a80 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -24,7 +24,8 @@ -export([new/1, run/4]). --export([run_aaequery/1]). +-export([run_aaequery/1, + run_listkeys/1]). -include("basho_bench.hrl"). @@ -276,7 +277,7 @@ run(aae_query, _KeyGen, _ValueGen, State) -> end, case {State#state.nominated_id, IsAlive} of {true, true} -> - lager:info("Skipping listkeys for overlap"), + lager:info("Skipping aae query for overlap"), {ok, State}; {true, false} -> Pid = spawn(?MODULE, run_aaequery, [State]), @@ -285,6 +286,25 @@ run(aae_query, _KeyGen, _ValueGen, State) -> {ok, State} end; +run(list_keys, _KeyGen, _ValueGen, State) -> + IsAlive = + case State#state.singleton_pid of + undefined -> + false; + LastPid -> + is_process_alive(LastPid) + end, + case {State#state.nominated_id, IsAlive} of + {true, true} -> + lager:info("Skipping listkeys for overlap"), + {ok, State}; + {true, false} -> + Pid = spawn(?MODULE, run_listkeys, [State]), + {ok, State#state{singleton_pid = Pid}}; + _ -> + {ok, State} + end; + run(Other, _, _, _) -> throw({unknown_operation, Other}). @@ -368,6 +388,31 @@ run_aaequery(State) -> {error, Reason, State} end. +run_listkeys(State) -> + SW = os:timestamp(), + lager:info("Commencing list keys request"), + + Host = inet_parse:ntoa(State#state.http_host), + Port = State#state.http_port, + Bucket = State#state.recordBucket, + + URLSrc = + "http://~s:~p/buckets/~s/keys?keys=true", + URL = io_lib:format(URLSrc, + [Host, Port, Bucket]), + + case json_get(URL, State#state.fold_timeout, false) of + {ok, {struct, KeyList}} -> + lager:info("List keys returned ~w keys in ~w seconds", + [length(KeyList), + timer:now_diff(os:timestamp(), SW)/1000000]), + + {ok, State}; + {error, Reason} -> + io:format("[~s:~p] ERROR - Reason: ~p~n", + [?MODULE, ?LINE, Reason]), + {error, Reason, State} + end. %% ==================================================================== %% Index seeds From 4fe0cf357dc7ce119103b33d6c77fef7fc11df1f Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Fri, 6 Oct 2017 10:14:49 +0100 Subject: [PATCH 43/75] Record key counts --- src/basho_bench_driver_nhs.erl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index d71c77a80..63ea80b20 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -377,9 +377,10 @@ run_aaequery(State) -> [Host, Port, Bucket, KeyStart, KeyEnd, MapFoldMod]), case json_get(URL, State#state.fold_timeout, false) of - {ok, {struct, _AAETree}} -> - lager:info("AAE query returned in ~w seconds", - [timer:now_diff(os:timestamp(), SW)/1000000]), + {ok, {struct, TreeL}} -> + {<<"count">>, Count} = lists:keyfind(<<"count">>, 1, TreeL), + lager:info("AAE query returned in ~w secondscovering ~s keys", + [timer:now_diff(os:timestamp(), SW)/1000000, Count]), {ok, State}; {error, Reason} -> @@ -402,7 +403,7 @@ run_listkeys(State) -> [Host, Port, Bucket]), case json_get(URL, State#state.fold_timeout, false) of - {ok, {struct, KeyList}} -> + {ok, {struct, [{<<"keys">>, KeyList}]}} -> lager:info("List keys returned ~w keys in ~w seconds", [length(KeyList), timer:now_diff(os:timestamp(), SW)/1000000]), From 330bfbc2ba908d715fd731fb647a17aa52a5ef8a Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Fri, 6 Oct 2017 10:32:01 +0100 Subject: [PATCH 44/75] Typo --- src/basho_bench_driver_nhs.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 63ea80b20..b2861bc6c 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -379,7 +379,7 @@ run_aaequery(State) -> case json_get(URL, State#state.fold_timeout, false) of {ok, {struct, TreeL}} -> {<<"count">>, Count} = lists:keyfind(<<"count">>, 1, TreeL), - lager:info("AAE query returned in ~w secondscovering ~s keys", + lager:info("AAE query returned in ~w seconds covering ~s keys", [timer:now_diff(os:timestamp(), SW)/1000000, Count]), {ok, State}; From 9a201f5aa1f42871f35d4f26c54efb7e621cf970 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 9 Nov 2017 21:17:38 +0000 Subject: [PATCH 45/75] Document valgen - balance "semi" compression --- .DS_Store | Bin 0 -> 6148 bytes src/basho_bench_valgen.erl | 5 ++++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..81229e8d26382bd3469cb3d9bb2de3f1954844ac GIT binary patch literal 6148 zcmeH~Jqp4=5QS&dB4Cr!avKle4VIuM@B*S@B?yZB9^E%TjnP_yyn&f-XEsBUS7b9H zqQmpN5$Q#wgBxXSVPuMYE)TiO>2iLYjtb*@FJ*K=2U&T%hcRwa*e@u>x3=Er<$CqZN!+^)bZi z-VT<$t|nVB+C_8t(7dzS6a&*}7cEF&S{)2jfC`Khm`C2*`M-mIoBu~GOsN1B_%j7` zvE6S6yi}g8AFpTiLso6w;GkcQ@b(jc#E#+>+ztE17GO=bASy8a2)GOkRN$uyya2`( B5q1Co literal 0 HcmV?d00001 diff --git a/src/basho_bench_valgen.erl b/src/basho_bench_valgen.erl index ed4c22e7a..5656ca306 100644 --- a/src/basho_bench_valgen.erl +++ b/src/basho_bench_valgen.erl @@ -133,7 +133,10 @@ init_altsource(1, undefined) -> ComboBlockFun = fun(_X, Acc) -> Bin1 = crypto:rand_bytes(4096), - Bin2 = create_random_textblock(16, RandomStrs), + Bin2 = create_random_textblock(32, RandomStrs), + % Both the compressible and uncompressible parts will be + % 4096 bytes in size. zlib will compress the compressible + % part down 3:1 <> end, Bytes = lists:foldl(ComboBlockFun, <<>>, lists:seq(1, 8192)), From 89685b43fce66086ef9aa0884a28370a2b840765 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Fri, 10 Nov 2017 14:42:46 +0000 Subject: [PATCH 46/75] Add segment_fold test --- src/basho_bench_driver_nhs.erl | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index b2861bc6c..812ffcd72 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -305,6 +305,25 @@ run(list_keys, _KeyGen, _ValueGen, State) -> {ok, State} end; +run(segment_fold, _KeyGen, _ValueGen, State) -> + IsAlive = + case State#state.singleton_pid of + undefined -> + false; + LastPid -> + is_process_alive(LastPid) + end, + case {State#state.nominated_id, IsAlive} of + {true, true} -> + lager:info("Skipping segment fold for overlap"), + {ok, State}; + {true, false} -> + Pid = spawn(?MODULE, run_segmentfold, [State]), + {ok, State#state{singleton_pid = Pid}}; + _ -> + {ok, State} + end; + run(Other, _, _, _) -> throw({unknown_operation, Other}). @@ -415,6 +434,44 @@ run_listkeys(State) -> {error, Reason, State} end. +run_segmentfold(State) -> + SW = os:timestamp(), + lager:info("Commencing segment fold request"), + + Host = inet_parse:ntoa(State#state.http_host), + Port = State#state.http_port, + Bucket = State#state.recordBucket, + + KeyStart = "0", + KeyEnd = "z", + + MapFoldMod = "riak_kv_segment_folder", + + % '{"check_presence": "false", + % "tree_size": "small", + % "segment_list": [1, 10001]}' + MapFoldOpts = + "eyJjaGVja19wcmVzZW5jZSI6ICJmYWxzZSIsICJ0cmVlX3NpemUiOiAic21hbGwiLCA" + ++ "ic2VnbWVudF9saXN0IjogWzEsIDEwMDAxXX0=", + + URLSrc = + "http://~s:~p/buckets/~s/index/$key/~s/~s?mapfold=true&mapfoldmod=~s" + ++ "&mapfoldoptions=~s", + URL = io_lib:format(URLSrc, + [Host, Port, Bucket, KeyStart, KeyEnd, + MapFoldMod, MapFoldOpts]), + + case json_get(URL, State#state.fold_timeout, false) of + {ok, {struct, [{<<"deltas">>, SegL}]}} -> + lager:info("Segment fold returned in ~w seconds finding ~w keys", + [timer:now_diff(os:timestamp(), SW)/1000000, length(SegL)]), + {ok, State}; + {error, Reason} -> + io:format("[~s:~p] ERROR - Reason: ~p~n", + [?MODULE, ?LINE, Reason]), + {error, Reason, State} + end. + %% ==================================================================== %% Index seeds %% ==================================================================== From 327752b53d61bc15715952ddfa873f6d020d1562 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 20 Nov 2017 16:37:18 +0000 Subject: [PATCH 47/75] Add get_unique Simulate better document bucket with addition of get_unique as well as put_unique --- examples/riakc_nhs.config | 8 +++---- src/basho_bench_driver_nhs.erl | 38 ++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 89248b724..a72196515 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -1,22 +1,22 @@ {mode, max}. -{duration, 3600}. +{duration, 720}. {report_interval, 10}. -{concurrent, 20}. +{concurrent, 80}. {driver, basho_bench_driver_nhs}. {key_generator, {pareto_int, 100000000}}. -{value_generator, {semi_compressible, 4000, 4000, 10, 0.1}}. +{value_generator, {semi_compressible, 6000, 6000, 8, 0.1}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. {riakc_pb_replies, 1}. -{operations, [{get_pb, 400}, {update_with2i, 100}, {put_unique, 20}, +{operations, [{get_pb, 400}, {update_with2i, 100}, {put_unique, 20}, {get_unique, 80}, {postcodequery_http, 1}, {dobquery_http, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 812ffcd72..cb2c7ec38 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -25,7 +25,8 @@ run/4]). -export([run_aaequery/1, - run_listkeys/1]). + run_listkeys/1, + run_segmentfold/1]). -include("basho_bench.hrl"). @@ -45,7 +46,8 @@ query_logfreq :: integer(), nominated_id :: boolean(), % ID 1 is nominated to do special work - singleton_pid :: pid() | undefined + singleton_pid :: pid() | undefined, + unique_key_count :: non_neg_integer() }). -define(QUERYLOG_FREQ, 1000). @@ -109,7 +111,7 @@ new(Id) -> ?INFO("Using pb target ~p:~p for worker ~p\n", [PBTargetIp, PBTargetPort, Id]), - + case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of {ok, Pid} -> NominatedID = Id == 1, @@ -123,7 +125,8 @@ new(Id) -> http_timeout = HTTPTimeout, fold_timeout = FoldTimeout, query_logfreq = random:uniform(?QUERYLOG_FREQ), - nominated_id = NominatedID}}; + nominated_id = NominatedID, + unique_key_count = 1}}; {error, Reason2} -> ?FAIL_MSG("Failed to connect riakc_pb_socket to ~p port ~p: ~p\n", [PBTargetIp, PBTargetPort, Reason2]) @@ -174,10 +177,11 @@ run(update_with2i, KeyGen, ValueGen, State) -> %% Put an object with a unique key and a non-compressable value run(put_unique, _KeyGen, _ValueGen, State) -> Pid = State#state.pb_pid, - Bucket = State#state.recordBucket, + Bucket = State#state.documentBucket, - Key = generate_uniquekey(), - Value = non_compressible_value(6000), + UKC = State#state.unique_key_count, + Key = generate_uniquekey(UKC), + Value = non_compressible_value(8000), Robj0 = riakc_obj:new(Bucket, to_binary(Key)), MD1 = riakc_obj:get_update_metadata(Robj0), @@ -188,6 +192,20 @@ run(put_unique, _KeyGen, _ValueGen, State) -> %% Write the object... case riakc_pb_socket:put(Pid, Robj2, State#state.pb_timeout) of ok -> + {ok, State#state{unique_key_count = UKC + 1}}; + {error, Reason} -> + {error, Reason, State} + end; +run(get_unique, _KeyGen, _ValueGen, State) -> + % Get one of the objects with unique keys + Pid = State#state.pb_pid, + Bucket = State#state.documentBucket, + UKC = State#state.unique_key_count, + Key = generate_uniquekey(random:uniform(UKC)), + case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of + {ok, _Obj} -> + {ok, State}; + {error, notfound} -> {ok, State}; {error, Reason} -> {error, Reason, State} @@ -506,12 +524,14 @@ lastmodified_index() -> [list_to_binary(F)]. -generate_uniquekey() -> +generate_uniquekey(Count) -> {{Year, Month, Day}, {Hr, Min, Sec}} = calendar:now_to_datetime(os:timestamp()), F = lists:flatten(io_lib:format(?DATETIME_FORMAT, [Year, Month, Day, Hr, Min, Sec])), - F0 = F ++ [base64:encode_to_string(crypto:rand_bytes(4))], + F0 = lists:sublist(F, 10) + ++ [base64:encode_to_string(crypto:rand_bytes(4))] + ++ integer_to_list(Count), list_to_binary(F0). non_compressible_value(Size) -> From a0dfc2639c6dda4d77a75af7cd094c87b0dbb5a9 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 20 Nov 2017 18:30:07 +0000 Subject: [PATCH 48/75] Config fiddling --- examples/riakc_nhs.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index a72196515..7482dcc00 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -9,7 +9,7 @@ {key_generator, {pareto_int, 100000000}}. -{value_generator, {semi_compressible, 6000, 6000, 8, 0.1}}. +{value_generator, {semi_compressible, 6000, 4000, 8, 0.2}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. From ae98aa2fa1aad0eff3d44a3fca90b9b1cd10ba16 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 20 Nov 2017 18:35:20 +0000 Subject: [PATCH 49/75] Use correct keygen --- examples/riakc_nhs.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 7482dcc00..a76a082f8 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -7,7 +7,7 @@ {driver, basho_bench_driver_nhs}. -{key_generator, {pareto_int, 100000000}}. +{key_generator, {eightytwenty_int, 100000000}}. {value_generator, {semi_compressible, 6000, 4000, 8, 0.2}}. From 0439c33d0ed112e6f40977c2193a9346387ae355 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Tue, 21 Nov 2017 10:10:30 +0000 Subject: [PATCH 50/75] Further review of NHS settings Reduce the relative frequency of regex queries --- examples/riakc_nhs.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index a76a082f8..d1f85c08c 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -16,8 +16,8 @@ {riakc_pb_replies, 1}. -{operations, [{get_pb, 400}, {update_with2i, 100}, {put_unique, 20}, {get_unique, 80}, - {postcodequery_http, 1}, {dobquery_http, 1}]}. +{operations, [{get_pb, 1000}, {update_with2i, 250}, {put_unique, 50}, {get_unique, 200}, + {postcodequery_http, 3}, {dobquery_http, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. From 4dff2068bdf31ad97ca8592ceea5679dd80d3719 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 23 Nov 2017 13:41:13 +0000 Subject: [PATCH 51/75] Fix get/put unique get_unique was never getting an object ... always a miss ... no wonder performance improved! --- src/basho_bench_driver_nhs.erl | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index cb2c7ec38..fa5369668 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -47,7 +47,8 @@ nominated_id :: boolean(), % ID 1 is nominated to do special work singleton_pid :: pid() | undefined, - unique_key_count :: non_neg_integer() + unique_key_count :: non_neg_integer(), + rand_keyid = crypto:rand_bytes(4) :: binary() }). -define(QUERYLOG_FREQ, 1000). @@ -180,7 +181,7 @@ run(put_unique, _KeyGen, _ValueGen, State) -> Bucket = State#state.documentBucket, UKC = State#state.unique_key_count, - Key = generate_uniquekey(UKC), + Key = generate_uniquekey(UKC, State#state.rand_keyid), Value = non_compressible_value(8000), Robj0 = riakc_obj:new(Bucket, to_binary(Key)), @@ -201,7 +202,7 @@ run(get_unique, _KeyGen, _ValueGen, State) -> Pid = State#state.pb_pid, Bucket = State#state.documentBucket, UKC = State#state.unique_key_count, - Key = generate_uniquekey(random:uniform(UKC)), + Key = generate_uniquekey(random:uniform(UKC), State#state.rand_keyid), case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of {ok, _Obj} -> {ok, State}; @@ -524,15 +525,10 @@ lastmodified_index() -> [list_to_binary(F)]. -generate_uniquekey(Count) -> - {{Year, Month, Day}, - {Hr, Min, Sec}} = calendar:now_to_datetime(os:timestamp()), - F = lists:flatten(io_lib:format(?DATETIME_FORMAT, - [Year, Month, Day, Hr, Min, Sec])), - F0 = lists:sublist(F, 10) - ++ [base64:encode_to_string(crypto:rand_bytes(4))] - ++ integer_to_list(Count), - list_to_binary(F0). +generate_uniquekey(Count, RandBytes) -> + C0 = [integer_to_list(Count)], + B0 = list_to_binary(lists:flatten(io_lib:format("~9..0B", C0))), + <>. non_compressible_value(Size) -> crypto:rand_bytes(Size). From 41305859bb0e5be0bc3fb58d8b38335c90d310ed Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 23 Nov 2017 13:48:28 +0000 Subject: [PATCH 52/75] De-tune sem-compress size To something more realistic --- examples/riakc_nhs.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index d1f85c08c..43adad007 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -9,7 +9,7 @@ {key_generator, {eightytwenty_int, 100000000}}. -{value_generator, {semi_compressible, 6000, 4000, 8, 0.2}}. +{value_generator, {semi_compressible, 5000, 3000, 5, 0.2}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. From 778b627c22efc5f0d7e5d32f9ca85e26469b58ab Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 23 Nov 2017 14:42:50 +0000 Subject: [PATCH 53/75] Fix number format --- src/basho_bench_driver_nhs.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index fa5369668..cac481d81 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -525,9 +525,8 @@ lastmodified_index() -> [list_to_binary(F)]. -generate_uniquekey(Count, RandBytes) -> - C0 = [integer_to_list(Count)], - B0 = list_to_binary(lists:flatten(io_lib:format("~9..0B", C0))), +generate_uniquekey(C, RandBytes) -> + B0 = list_to_binary(lists:flatten(io_lib:format("~9..0B", [C]))), <>. non_compressible_value(Size) -> From 2343743a42fbf7c544ca9c6c3d993ad9fc1dfa53 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 27 Nov 2017 11:14:16 +0000 Subject: [PATCH 54/75] More PUT uniques This seems more realistic --- examples/riakc_nhs.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 43adad007..99bc9c1a9 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -16,7 +16,7 @@ {riakc_pb_replies, 1}. -{operations, [{get_pb, 1000}, {update_with2i, 250}, {put_unique, 50}, {get_unique, 200}, +{operations, [{get_pb, 1000}, {update_with2i, 250}, {put_unique, 100}, {get_unique, 200}, {postcodequery_http, 3}, {dobquery_http, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). From f977acc0b88989e83de442c7816647a8d49d8690 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sat, 26 May 2018 11:21:44 +0100 Subject: [PATCH 55/75] Add force_aae option to basho_bench Allows for a GET every 10 seconds which will prompt an AAE exchange --- examples/riakc_nhs.config | 4 ++-- src/basho_bench_driver_nhs.erl | 30 +++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 99bc9c1a9..df8955f9b 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -16,8 +16,8 @@ {riakc_pb_replies, 1}. -{operations, [{get_pb, 1000}, {update_with2i, 250}, {put_unique, 100}, {get_unique, 200}, - {postcodequery_http, 3}, {dobquery_http, 1}]}. +{operations, [{get_pb, 4000}, {update_with2i, 1000}, {put_unique, 400}, {get_unique, 800}, + {postcodequery_http, 12}, {dobquery_http, 4}, {force_aae, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index cac481d81..cefa9eeab 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -48,10 +48,12 @@ % ID 1 is nominated to do special work singleton_pid :: pid() | undefined, unique_key_count :: non_neg_integer(), - rand_keyid = crypto:rand_bytes(4) :: binary() + rand_keyid = crypto:rand_bytes(4) :: binary(), + last_forceaae = os:timestamp() :: erlang:timestamp() }). -define(QUERYLOG_FREQ, 1000). +-define(FORCEAAE_FREQ, 10). % Every 10 seconds -define(POSTCODE_AREAS, [{1, "AB"}, {2, "AL"}, {3, "B"}, {4, "BA"}, {5, "BB"}, @@ -343,6 +345,31 @@ run(segment_fold, _KeyGen, _ValueGen, State) -> {ok, State} end; +run(force_aae, KeyGen, ValueGen, State) -> + SinceLastForceSec = + timer:now_diff(os:timestamp(), State#state.last_forceaae)/1000000, + case {State#state.nominated_id, SinceLastForceSec > ?FORCEAAE_FREQ} of + {true, true} -> + Host = inet_parse:ntoa(State#state.http_host), + Port = State#state.http_port, + Bucket = State#state.recordBucket, + Key = to_binary(KeyGen()), + Timeout = State#state.http_timeout, + + URLSrc = "http://~s:~p/buckets/~s/keys/~s?force_aae=true", + URL = io_lib:format(URLSrc, [Host, Port, Bucket, Key]), + Target = lists:flatten(URL), + + case ibrowse:send_req(Target, [], get, [], [], Timeout) of + {ok, "200", _, _Body} -> + {ok, State#state{last_forceaae = os:timestamp()}}; + Other -> + {error, Other, State} + end; + _ -> + run(get_pb, KeyGen, ValueGen, State) + end; + run(Other, _, _, _) -> throw({unknown_operation, Other}). @@ -453,6 +480,7 @@ run_listkeys(State) -> {error, Reason, State} end. + run_segmentfold(State) -> SW = os:timestamp(), lager:info("Commencing segment fold request"), From c072f3bf160097cef57984b8327400a44847eef2 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Sat, 26 May 2018 15:41:33 +0100 Subject: [PATCH 56/75] URL format - requires strings not binaries --- src/basho_bench_driver_nhs.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index cefa9eeab..a149d5972 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -352,11 +352,11 @@ run(force_aae, KeyGen, ValueGen, State) -> {true, true} -> Host = inet_parse:ntoa(State#state.http_host), Port = State#state.http_port, - Bucket = State#state.recordBucket, - Key = to_binary(KeyGen()), + Bucket = binary_to_list(State#state.recordBucket), + Key = KeyGen(), Timeout = State#state.http_timeout, - URLSrc = "http://~s:~p/buckets/~s/keys/~s?force_aae=true", + URLSrc = "http://~s:~p/buckets/~s/keys/~p?force_aae=true", URL = io_lib:format(URLSrc, [Host, Port, Bucket, Key]), Target = lists:flatten(URL), From 54602544385d4210c08aaeb7e7958d8e6f820c4b Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 9 Jul 2018 10:21:18 +0100 Subject: [PATCH 57/75] ForceAAE changes --- src/basho_bench_driver_nhs.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index a149d5972..ce34e7bde 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -117,7 +117,7 @@ new(Id) -> case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of {ok, Pid} -> - NominatedID = Id == 1, + NominatedID = Id == 7, {ok, #state { pb_pid = Pid, http_host = HTTPTargetIp, @@ -363,6 +363,8 @@ run(force_aae, KeyGen, ValueGen, State) -> case ibrowse:send_req(Target, [], get, [], [], Timeout) of {ok, "200", _, _Body} -> {ok, State#state{last_forceaae = os:timestamp()}}; + {ok, "404", _, _NotFound} -> + {ok, State#state{last_forceaae = os:timestamp()}}; Other -> {error, Other, State} end; From 4b75c981bb6f4e9ad880a2b6c555c5b1296b1d55 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 9 Jul 2018 14:46:59 +0100 Subject: [PATCH 58/75] NHS Config with no not_found Stop having get requests where not_found is an expected response. This will slow throughput in early parts of the test - but should make sure the tests are more relaistic, not being dominated by the speed of not_founds for multiple hours. --- examples/riakc_nhs.config | 20 ++++--- src/basho_bench_driver_nhs.erl | 99 ++++++++++++++++++++++++++++++++-- 2 files changed, 108 insertions(+), 11 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index df8955f9b..406cb3708 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -7,17 +7,25 @@ {driver, basho_bench_driver_nhs}. +%% Ignored by alwaysget and unique operations {key_generator, {eightytwenty_int, 100000000}}. {value_generator, {semi_compressible, 5000, 3000, 5, 0.2}}. +%% For alwaysget operations what is: +%% - the maximum number of keys per worker +%% - the minimum number of keys per worker (at this level update will always put new) +%% - whether the inserts shoudl be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key +{alwaysget, {1250000, 25000, skew_order}}. + {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. {riakc_pb_replies, 1}. -{operations, [{get_pb, 4000}, {update_with2i, 1000}, {put_unique, 400}, {get_unique, 800}, - {postcodequery_http, 12}, {dobquery_http, 4}, {force_aae, 1}]}. +{operations, [{alwaysget_pb, 600}, {alwaysget_updatewith2i, 200}, + {put_unique, 64}, {get_unique, 132}, + {postcodequery_http, 3}, {dobquery_http, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). %% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. @@ -29,9 +37,9 @@ %% default timeout if the read/write/listkeys/mapreduce timeout is not %% specified. -{pb_timeout_general, 30000}. -{pb_timeout_read, 5000}. -{pb_timeout_write, 5000}. -{pb_timeout_listkeys, 50000}. +{pb_timeout_general, 60000}. +{pb_timeout_read, 10000}. +{pb_timeout_write, 10000}. +{pb_timeout_listkeys, 60000}. %% The general timeout will be used because this specific item is commented: %% {pb_timeout_mapreduce, 50000}. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index ce34e7bde..a76cc6753 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -39,6 +39,9 @@ pb_timeout, http_timeout, fold_timeout, + alwaysget_perworker_maxkeycount = 1 :: integer(), + alwaysget_perworker_minkeycount = 1 :: integer(), + alwaysget_keyorder = key_order :: key_order|skew_order, postcodeq_count = 0 :: integer(), postcodeq_sum = 0 :: integer(), dobq_count = 0 :: integer(), @@ -47,7 +50,8 @@ nominated_id :: boolean(), % ID 1 is nominated to do special work singleton_pid :: pid() | undefined, - unique_key_count :: non_neg_integer(), + unique_key_count = 1 :: non_neg_integer(), + alwaysget_key_count = 1 :: non_neg_integer(), rand_keyid = crypto:rand_bytes(4) :: binary(), last_forceaae = os:timestamp() :: erlang:timestamp() }). @@ -115,6 +119,8 @@ new(Id) -> PBTargetPort, Id]), + {AGMaxKC, AGMinKC, AGKeyOrder} = bash_bench_config:get(alwaysget, {1, 1, key_order}), + case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of {ok, Pid} -> NominatedID = Id == 7, @@ -129,7 +135,12 @@ new(Id) -> fold_timeout = FoldTimeout, query_logfreq = random:uniform(?QUERYLOG_FREQ), nominated_id = NominatedID, - unique_key_count = 1}}; + unique_key_count = 1, + alwaysget_key_count = 1, + alwaysget_perworker_maxkeycount = AGMaxKC, + alwaysget_perworker_minkeycount = AGMinKC, + alwaysget_keyorder = AGKeyOrder + }}; {error, Reason2} -> ?FAIL_MSG("Failed to connect riakc_pb_socket to ~p port ~p: ~p\n", [PBTargetIp, PBTargetPort, Reason2]) @@ -149,6 +160,67 @@ run(get_pb, KeyGen, _ValueGen, State) -> {error, Reason, State} end; +run(alwaysget_pb, _KeyGen, _ValueGen, State) -> + % Get one of the objects with unique keys + Pid = State#state.pb_pid, + Bucket = State#state.documentBucket, + AGKC = State#state.alwaysget_key_count, + KeyInt = eightytwenty_keycount(AGKC), + Key = generate_uniquekey(KeyInt, State#state.rand_keyid, + State#state.alwaysget_keyorder), + + case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of + {ok, _Obj} -> + {ok, State}; + {error, Reason} -> + % not_found is not OK + {error, Reason, State} + end; + +run(alwaysget_updatewith2i, _KeyGen, ValueGen, State) -> + Pid = State#state.pb_pid, + Bucket = State#state.documentBucket, + AGKC = State#state.alwaysget_key_count, + Value = ValueGen(), + KeyInt = eightytwenty_keycount(AGKC), + AboveMin = KeyInt < State#state.alwaysget_perworker_minkeycount, + BelowMax = KeyInt < State#state.alwaysget_perworker_maxkeycount, + {Robj0, NewAGKC} = + case AboveMin and BelowMax of + true -> + % Expand the key count + ExpansionKey = + generate_uniquekey(AGKC + 1, State#state.rand_keyid, + State#state.alwaysget_keyorder), + {riakc_obj:new(Bucket, ExpansionKey), + AGKC + 1}; + false -> + % update an existing key + ExistingKey = + generate_uniquekey(KeyInt, State#state.rand_keyid, + State#state.alwaysget_keyorder), + {ok, Robj} = + riakc_pb_socket:get(Pid, + Bucket, ExistingKey, + State#state.pb_timeout), + {Robj, AGKC} + end, + + MD0 = riakc_obj:get_update_metadata(Robj0), + MD1 = riakc_obj:clear_secondary_indexes(MD0), + MD2 = riakc_obj:set_secondary_index(MD1, generate_binary_indexes()), + Robj1 = riakc_obj:update_value(Robj0, Value), + Robj2 = riakc_obj:update_metadata(Robj1, MD2), + + %% Write the object... + case riakc_pb_socket:put(Pid, Robj2, State#state.pb_timeout) of + ok -> + {ok, State#state{alwaysget_key_count = NewAGKC}}; + {error, Reason} -> + {error, Reason, State} + end; + + %% Update an object with secondary indexes. run(update_with2i, KeyGen, ValueGen, State) -> Pid = State#state.pb_pid, @@ -183,7 +255,7 @@ run(put_unique, _KeyGen, _ValueGen, State) -> Bucket = State#state.documentBucket, UKC = State#state.unique_key_count, - Key = generate_uniquekey(UKC, State#state.rand_keyid), + Key = generate_uniquekey(UKC, State#state.rand_keyid, key_order), Value = non_compressible_value(8000), Robj0 = riakc_obj:new(Bucket, to_binary(Key)), @@ -204,7 +276,9 @@ run(get_unique, _KeyGen, _ValueGen, State) -> Pid = State#state.pb_pid, Bucket = State#state.documentBucket, UKC = State#state.unique_key_count, - Key = generate_uniquekey(random:uniform(UKC), State#state.rand_keyid), + Key = generate_uniquekey(random:uniform(UKC), + State#state.rand_keyid, + key_order), case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of {ok, _Obj} -> {ok, State}; @@ -555,11 +629,26 @@ lastmodified_index() -> [list_to_binary(F)]. -generate_uniquekey(C, RandBytes) -> +generate_uniquekey(C, RandBytes, skew_order) -> + H0 = erlang:phash2(C), + <>; +generate_uniquekey(C, RandBytes, key_order) -> B0 = list_to_binary(lists:flatten(io_lib:format("~9..0B", [C]))), <>. + non_compressible_value(Size) -> crypto:rand_bytes(Size). +eightytwenty_keycount(UKC) -> + % 80% of the time choose a key in the bottom 20% of the + % result range, and 20% of the time in the upper 80% of the range + TwentyPoint = random:uniform(UKC div 5), + case random:uniform(UKC) < TwentyPoint of + true -> + random:uniform(UKC - TwentyPoint) + TwentyPoint; + false -> + random:uniform(TwentyPoint) + end. + \ No newline at end of file From 52ce42c9921f33ef6153358770d16ddcf3a035b6 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 9 Jul 2018 14:50:48 +0100 Subject: [PATCH 59/75] Change proportions of requests --- examples/riakc_nhs.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 406cb3708..029afa803 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -23,8 +23,8 @@ {riakc_pb_replies, 1}. -{operations, [{alwaysget_pb, 600}, {alwaysget_updatewith2i, 200}, - {put_unique, 64}, {get_unique, 132}, +{operations, [{alwaysget_pb, 504}, {alwaysget_updatewith2i, 300}, + {put_unique, 64}, {get_unique, 128}, {postcodequery_http, 3}, {dobquery_http, 1}]}. %% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). From 8a990272827e3128ef6290d0d367f1c002e79ef6 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Mon, 9 Jul 2018 15:04:51 +0100 Subject: [PATCH 60/75] Config used In testing - use a 24 hour config with more workers --- examples/riakc_nhs.config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 029afa803..ab80c9580 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -1,9 +1,9 @@ {mode, max}. -{duration, 720}. +{duration, 1440}. {report_interval, 10}. -{concurrent, 80}. +{concurrent, 100}. {driver, basho_bench_driver_nhs}. @@ -16,7 +16,7 @@ %% - the maximum number of keys per worker %% - the minimum number of keys per worker (at this level update will always put new) %% - whether the inserts shoudl be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key -{alwaysget, {1250000, 25000, skew_order}}. +{alwaysget, {1000000, 50000, skew_order}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. From 2ab383b3f39d0fb960868ba18bff9c502d454a3f Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Tue, 10 Jul 2018 10:42:39 +0100 Subject: [PATCH 61/75] Bug fixes Typos etc --- src/basho_bench_driver_nhs.erl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index a76cc6753..3c0844078 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -119,7 +119,7 @@ new(Id) -> PBTargetPort, Id]), - {AGMaxKC, AGMinKC, AGKeyOrder} = bash_bench_config:get(alwaysget, {1, 1, key_order}), + {AGMaxKC, AGMinKC, AGKeyOrder} = basho_bench_config:get(alwaysget, {1, 1, key_order}), case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of {ok, Pid} -> @@ -136,7 +136,7 @@ new(Id) -> query_logfreq = random:uniform(?QUERYLOG_FREQ), nominated_id = NominatedID, unique_key_count = 1, - alwaysget_key_count = 1, + alwaysget_key_count = 0, alwaysget_perworker_maxkeycount = AGMaxKC, alwaysget_perworker_minkeycount = AGMinKC, alwaysget_keyorder = AGKeyOrder @@ -169,17 +169,20 @@ run(alwaysget_pb, _KeyGen, _ValueGen, State) -> Key = generate_uniquekey(KeyInt, State#state.rand_keyid, State#state.alwaysget_keyorder), - case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of - {ok, _Obj} -> + case {riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout), KeyInt} of + {{ok, _Obj}, _} -> {ok, State}; - {error, Reason} -> + {{error, notfound}, 1} -> + lager:info("Not Found with KeyInt of ~w AGKC ~w", [KeyInt, AGKC]), + {ok, State}; + {{error, Reason}, _KeyInt} -> % not_found is not OK {error, Reason, State} end; run(alwaysget_updatewith2i, _KeyGen, ValueGen, State) -> Pid = State#state.pb_pid, - Bucket = State#state.documentBucket, + Bucket = State#state.recordBucket, AGKC = State#state.alwaysget_key_count, Value = ValueGen(), KeyInt = eightytwenty_keycount(AGKC), @@ -644,11 +647,11 @@ non_compressible_value(Size) -> eightytwenty_keycount(UKC) -> % 80% of the time choose a key in the bottom 20% of the % result range, and 20% of the time in the upper 80% of the range - TwentyPoint = random:uniform(UKC div 5), - case random:uniform(UKC) < TwentyPoint of + TwentyPoint = random:uniform(max(1, UKC div 5)), + case random:uniform(max(1, UKC)) < TwentyPoint of true -> - random:uniform(UKC - TwentyPoint) + TwentyPoint; + random:uniform(UKC - TwentyPoint) + max(1, TwentyPoint); false -> - random:uniform(TwentyPoint) + random:uniform(max(1, TwentyPoint)) end. \ No newline at end of file From c2545debb0445fef9df1f39e7dd060f040b5f50f Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Tue, 10 Jul 2018 10:44:44 +0100 Subject: [PATCH 62/75] Used record bucket for alwaysget --- src/basho_bench_driver_nhs.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 3c0844078..d4954fdbb 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -163,7 +163,7 @@ run(get_pb, KeyGen, _ValueGen, State) -> run(alwaysget_pb, _KeyGen, _ValueGen, State) -> % Get one of the objects with unique keys Pid = State#state.pb_pid, - Bucket = State#state.documentBucket, + Bucket = State#state.recordBucket, AGKC = State#state.alwaysget_key_count, KeyInt = eightytwenty_keycount(AGKC), Key = generate_uniquekey(KeyInt, State#state.rand_keyid, From 7bdc15531b881670d5a981a7c9ad0b139e19c373 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Tue, 10 Jul 2018 11:43:18 +0100 Subject: [PATCH 63/75] Make sure keys convert to JSON Otherwise they will throw errors when processing 2i query results --- src/basho_bench_driver_nhs.erl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index d4954fdbb..39c912fcd 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -633,11 +633,13 @@ lastmodified_index() -> generate_uniquekey(C, RandBytes, skew_order) -> - H0 = erlang:phash2(C), - <>; + H0 = convert_tolist(erlang:phash2(C)), + RB = convert_tolist(RandBytes), + <>; generate_uniquekey(C, RandBytes, key_order) -> - B0 = list_to_binary(lists:flatten(io_lib:format("~9..0B", [C]))), - <>. + B0 = convert_tolist(C), + RB = convert_tolist(RandBytes), + <>. non_compressible_value(Size) -> @@ -654,4 +656,10 @@ eightytwenty_keycount(UKC) -> false -> random:uniform(max(1, TwentyPoint)) end. - \ No newline at end of file + + +convert_tolist(I) when is_integer(I) -> + list_to_binary(lists:flatten(io_lib:format("~9..0B", [I]))); +convert_tolist(Bin) -> + <> = Bin, + convert_tolist(I). \ No newline at end of file From 93ecbc1889363e13f47419d223790d5c14f314d6 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 11 Jul 2018 10:14:50 +0100 Subject: [PATCH 64/75] Key space expanding too quickly AboveMin was BelowMin, and due to 80/20 rule was not frequently being triggered - too many additions, not enough updates. Also too high a proportion of updates compared to GETs. Need to avoid running out of disk space in test environment, so overall key space size reduced. --- examples/riakc_nhs.config | 9 ++++----- src/basho_bench_driver_nhs.erl | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index ab80c9580..ef813e9a8 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -13,17 +13,16 @@ {value_generator, {semi_compressible, 5000, 3000, 5, 0.2}}. %% For alwaysget operations what is: -%% - the maximum number of keys per worker -%% - the minimum number of keys per worker (at this level update will always put new) -%% - whether the inserts shoudl be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key -{alwaysget, {1000000, 50000, skew_order}}. +%% - the maximum number of keys per worker (max number of keys = this * concurrent) +%% - whether the inserts should be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key +{alwaysget, {600000, skew_order}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. {riakc_pb_replies, 1}. -{operations, [{alwaysget_pb, 504}, {alwaysget_updatewith2i, 300}, +{operations, [{alwaysget_pb, 612}, {alwaysget_updatewith2i, 192}, {put_unique, 64}, {get_unique, 128}, {postcodequery_http, 3}, {dobquery_http, 1}]}. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 39c912fcd..683dcaf18 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -40,7 +40,6 @@ http_timeout, fold_timeout, alwaysget_perworker_maxkeycount = 1 :: integer(), - alwaysget_perworker_minkeycount = 1 :: integer(), alwaysget_keyorder = key_order :: key_order|skew_order, postcodeq_count = 0 :: integer(), postcodeq_sum = 0 :: integer(), @@ -119,7 +118,7 @@ new(Id) -> PBTargetPort, Id]), - {AGMaxKC, AGMinKC, AGKeyOrder} = basho_bench_config:get(alwaysget, {1, 1, key_order}), + {AGMaxKC, AGKeyOrder} = basho_bench_config:get(alwaysget, {1, key_order}), case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of {ok, Pid} -> @@ -138,7 +137,6 @@ new(Id) -> unique_key_count = 1, alwaysget_key_count = 0, alwaysget_perworker_maxkeycount = AGMaxKC, - alwaysget_perworker_minkeycount = AGMinKC, alwaysget_keyorder = AGKeyOrder }}; {error, Reason2} -> @@ -186,15 +184,24 @@ run(alwaysget_updatewith2i, _KeyGen, ValueGen, State) -> AGKC = State#state.alwaysget_key_count, Value = ValueGen(), KeyInt = eightytwenty_keycount(AGKC), - AboveMin = KeyInt < State#state.alwaysget_perworker_minkeycount, - BelowMax = KeyInt < State#state.alwaysget_perworker_maxkeycount, + ToExtend = + random:uniform(State#state.alwaysget_perworker_maxkeycount) > AGKC, + {Robj0, NewAGKC} = - case AboveMin and BelowMax of + case ToExtend of true -> % Expand the key count ExpansionKey = generate_uniquekey(AGKC + 1, State#state.rand_keyid, State#state.alwaysget_keyorder), + case {AGKC div 1000, State#state.nominated_id} of + {0, true} -> + lager:info("Always grow key count passing ~w " + ++ "for nominated worker", + [AGKC]); + _ -> + ok + end, {riakc_obj:new(Bucket, ExpansionKey), AGKC + 1}; false -> From c95516cbf2f1f44d2e4f17723061b9a5c4c76c16 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 11 Jul 2018 10:42:17 +0100 Subject: [PATCH 65/75] Too many changes Disk space ran out 18 hours into the test. Should be enough to reduce proportion of updates, and reduce key space by 20% (not 40%) --- examples/riakc_nhs.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index ef813e9a8..8803e30c4 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -15,7 +15,7 @@ %% For alwaysget operations what is: %% - the maximum number of keys per worker (max number of keys = this * concurrent) %% - whether the inserts should be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key -{alwaysget, {600000, skew_order}}. +{alwaysget, {800000, skew_order}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. From 00c0f164da6c3e4044abfce4e85cd438618c25d9 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 11 Jul 2018 10:44:23 +0100 Subject: [PATCH 66/75] Revert "Too many changes" This reverts commit c95516cbf2f1f44d2e4f17723061b9a5c4c76c16. --- examples/riakc_nhs.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 8803e30c4..ef813e9a8 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -15,7 +15,7 @@ %% For alwaysget operations what is: %% - the maximum number of keys per worker (max number of keys = this * concurrent) %% - whether the inserts should be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key -{alwaysget, {800000, skew_order}}. +{alwaysget, {600000, skew_order}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. From 83f226075a1561c81924506a5ddd0b121d2eec6c Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 11 Jul 2018 13:33:41 +0100 Subject: [PATCH 67/75] Log every thousand increments Not every increment below 1000. D'oh. --- src/basho_bench_driver_nhs.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 683dcaf18..881ffa44b 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -194,7 +194,7 @@ run(alwaysget_updatewith2i, _KeyGen, ValueGen, State) -> ExpansionKey = generate_uniquekey(AGKC + 1, State#state.rand_keyid, State#state.alwaysget_keyorder), - case {AGKC div 1000, State#state.nominated_id} of + case {AGKC rem 1000, State#state.nominated_id} of {0, true} -> lager:info("Always grow key count passing ~w " ++ "for nominated worker", From d73e4f84436c5ea148a2422f401551e226fc8b50 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 18 Jul 2018 11:59:37 +0100 Subject: [PATCH 68/75] Add clincials basho_bench clincials environment has a different profile - add a specific basho_bench for this --- examples/riakc_nhs_clinicals.config | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 examples/riakc_nhs_clinicals.config diff --git a/examples/riakc_nhs_clinicals.config b/examples/riakc_nhs_clinicals.config new file mode 100644 index 000000000..2dc22d887 --- /dev/null +++ b/examples/riakc_nhs_clinicals.config @@ -0,0 +1,43 @@ +{mode, max}. + +{duration, 1440}. +{report_interval, 10}. + +{concurrent, 100}. + +{driver, basho_bench_driver_nhs}. + +%% Ignored by alwaysget and unique operations +{key_generator, {eightytwenty_int, 100000000}}. + +{value_generator, {semi_compressible, 80000, 20000, 2, 0.1}}. + +%% For alwaysget operations what is: +%% - the maximum number of keys per worker (max number of keys = this * concurrent) +%% - whether the inserts should be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key +{alwaysget, {600000, skew_order}}. + +{pb_ips, [{127,0,0,1}]}. +{http_ips, [{127,0,0,1}]}. + +{riakc_pb_replies, 1}. + +{operations, [{alwaysget_pb, 700}, {alwaysget_updatewith2i, 120}, + {put_unique, 70}, {get_unique, 110}]}. + +%% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). +%% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. +{pb_connect_options, [{auto_reconnect, true}]}. + +%% Overrides for the PB client's default 60 second timeout, on a +%% per-type-of-operation basis. All timeout units are specified in +%% milliseconds. The pb_timeout_general config item provides a +%% default timeout if the read/write/listkeys/mapreduce timeout is not +%% specified. + +{pb_timeout_general, 60000}. +{pb_timeout_read, 10000}. +{pb_timeout_write, 10000}. +{pb_timeout_listkeys, 60000}. +%% The general timeout will be used because this specific item is commented: +%% {pb_timeout_mapreduce, 50000}. From 9bc7cc8e8a7b21c4b91f1a59ccbab18b2a9a90fd Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 18 Jul 2018 12:15:05 +0100 Subject: [PATCH 69/75] Reduce key count Due to disk space issues --- examples/riakc_nhs_clinicals.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/riakc_nhs_clinicals.config b/examples/riakc_nhs_clinicals.config index 2dc22d887..e8b9ae63b 100644 --- a/examples/riakc_nhs_clinicals.config +++ b/examples/riakc_nhs_clinicals.config @@ -15,7 +15,7 @@ %% For alwaysget operations what is: %% - the maximum number of keys per worker (max number of keys = this * concurrent) %% - whether the inserts should be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key -{alwaysget, {600000, skew_order}}. +{alwaysget, {400000, skew_order}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. From 1444e6e3bbf9d939c23365813ece482ef07afcce Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Wed, 18 Jul 2018 17:13:28 +0100 Subject: [PATCH 70/75] Set minimum keys for always get So that there is a natural pre-load stage up to a minumum database size --- examples/riakc_nhs.config | 2 +- examples/riakc_nhs_clinicals.config | 2 +- src/basho_bench_driver_nhs.erl | 36 ++++++++++++++++++----------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index ef813e9a8..79c193706 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -15,7 +15,7 @@ %% For alwaysget operations what is: %% - the maximum number of keys per worker (max number of keys = this * concurrent) %% - whether the inserts should be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key -{alwaysget, {600000, skew_order}}. +{alwaysget, {600000, 1, skew_order}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. diff --git a/examples/riakc_nhs_clinicals.config b/examples/riakc_nhs_clinicals.config index e8b9ae63b..c477d0891 100644 --- a/examples/riakc_nhs_clinicals.config +++ b/examples/riakc_nhs_clinicals.config @@ -15,7 +15,7 @@ %% For alwaysget operations what is: %% - the maximum number of keys per worker (max number of keys = this * concurrent) %% - whether the inserts should be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key -{alwaysget, {400000, skew_order}}. +{alwaysget, {400000, 50000, skew_order}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 881ffa44b..e2857ccb9 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -40,6 +40,7 @@ http_timeout, fold_timeout, alwaysget_perworker_maxkeycount = 1 :: integer(), + alwayshet_perworker_minkeycount = 1 :: integer(), alwaysget_keyorder = key_order :: key_order|skew_order, postcodeq_count = 0 :: integer(), postcodeq_sum = 0 :: integer(), @@ -118,7 +119,8 @@ new(Id) -> PBTargetPort, Id]), - {AGMaxKC, AGKeyOrder} = basho_bench_config:get(alwaysget, {1, key_order}), + {AGMaxKC, AGMinKC, AGKeyOrder} = + basho_bench_config:get(alwaysget, {1, 1, key_order}), case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of {ok, Pid} -> @@ -137,6 +139,7 @@ new(Id) -> unique_key_count = 1, alwaysget_key_count = 0, alwaysget_perworker_maxkeycount = AGMaxKC, + alwayshet_perworker_minkeycount = AGMinKC, alwaysget_keyorder = AGKeyOrder }}; {error, Reason2} -> @@ -163,19 +166,26 @@ run(alwaysget_pb, _KeyGen, _ValueGen, State) -> Pid = State#state.pb_pid, Bucket = State#state.recordBucket, AGKC = State#state.alwaysget_key_count, - KeyInt = eightytwenty_keycount(AGKC), - Key = generate_uniquekey(KeyInt, State#state.rand_keyid, - State#state.alwaysget_keyorder), + case AGKC > State#state.alwayshet_perworker_minkeycount of + true -> - case {riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout), KeyInt} of - {{ok, _Obj}, _} -> - {ok, State}; - {{error, notfound}, 1} -> - lager:info("Not Found with KeyInt of ~w AGKC ~w", [KeyInt, AGKC]), - {ok, State}; - {{error, Reason}, _KeyInt} -> - % not_found is not OK - {error, Reason, State} + KeyInt = eightytwenty_keycount(AGKC), + Key = generate_uniquekey(KeyInt, State#state.rand_keyid, + State#state.alwaysget_keyorder), + + case riakc_pb_socket:get(Pid, + Bucket, Key, + State#state.pb_timeout) of + {ok, _Obj} -> + {ok, State}; + {error, Reason} -> + % not_found is not OK + {error, Reason, State} + end; + + false -> + {silent, State} + end; run(alwaysget_updatewith2i, _KeyGen, ValueGen, State) -> From f02cd711d1bbf11ec819ecd0adc3e0a7949651ba Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 19 Jul 2018 08:48:24 +0100 Subject: [PATCH 71/75] Allow unique to be skew_order And allow for change of value size. clinicals documents ar enot base don internalID, and so will be in a random order --- examples/riakc_nhs_clinicals.config | 5 +++-- src/basho_bench_driver_nhs.erl | 26 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/examples/riakc_nhs_clinicals.config b/examples/riakc_nhs_clinicals.config index c477d0891..21fe7dedd 100644 --- a/examples/riakc_nhs_clinicals.config +++ b/examples/riakc_nhs_clinicals.config @@ -14,8 +14,9 @@ %% For alwaysget operations what is: %% - the maximum number of keys per worker (max number of keys = this * concurrent) -%% - whether the inserts should be in key_order, or whether the order should be skewed by a 1 byte hash at the head of the key -{alwaysget, {400000, 50000, skew_order}}. +%% - whether the inserts should be in key_order +{alwaysget, {300000, 120000, skew_order}}. +{unique, {7000, skew_order}}. {pb_ips, [{127,0,0,1}]}. {http_ips, [{127,0,0,1}]}. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index e2857ccb9..ab5f588c2 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -40,8 +40,10 @@ http_timeout, fold_timeout, alwaysget_perworker_maxkeycount = 1 :: integer(), - alwayshet_perworker_minkeycount = 1 :: integer(), - alwaysget_keyorder = key_order :: key_order|skew_order, + alwaysget_perworker_minkeycount = 1 :: integer(), + alwaysget_keyorder :: key_order|skew_order, + unique_size :: integer(), + unique_keyorder :: key_order|skew_order, postcodeq_count = 0 :: integer(), postcodeq_sum = 0 :: integer(), dobq_count = 0 :: integer(), @@ -121,6 +123,8 @@ new(Id) -> {AGMaxKC, AGMinKC, AGKeyOrder} = basho_bench_config:get(alwaysget, {1, 1, key_order}), + {DocSize, DocKeyOrder} = + basho_bench_config:get(unique, {8000, key_order}), case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of {ok, Pid} -> @@ -139,8 +143,10 @@ new(Id) -> unique_key_count = 1, alwaysget_key_count = 0, alwaysget_perworker_maxkeycount = AGMaxKC, - alwayshet_perworker_minkeycount = AGMinKC, - alwaysget_keyorder = AGKeyOrder + alwaysget_perworker_minkeycount = AGMinKC, + alwaysget_keyorder = AGKeyOrder, + unique_size = DocSize, + unique_keyorder = DocKeyOrder }}; {error, Reason2} -> ?FAIL_MSG("Failed to connect riakc_pb_socket to ~p port ~p: ~p\n", @@ -166,7 +172,7 @@ run(alwaysget_pb, _KeyGen, _ValueGen, State) -> Pid = State#state.pb_pid, Bucket = State#state.recordBucket, AGKC = State#state.alwaysget_key_count, - case AGKC > State#state.alwayshet_perworker_minkeycount of + case AGKC > State#state.alwaysget_perworker_minkeycount of true -> KeyInt = eightytwenty_keycount(AGKC), @@ -275,8 +281,12 @@ run(put_unique, _KeyGen, _ValueGen, State) -> Bucket = State#state.documentBucket, UKC = State#state.unique_key_count, - Key = generate_uniquekey(UKC, State#state.rand_keyid, key_order), - Value = non_compressible_value(8000), + Key = + generate_uniquekey(UKC, + State#state.rand_keyid, + State#state.unique_keyorder), + + Value = non_compressible_value(State#state.unique_size), Robj0 = riakc_obj:new(Bucket, to_binary(Key)), MD1 = riakc_obj:get_update_metadata(Robj0), @@ -298,7 +308,7 @@ run(get_unique, _KeyGen, _ValueGen, State) -> UKC = State#state.unique_key_count, Key = generate_uniquekey(random:uniform(UKC), State#state.rand_keyid, - key_order), + State#state.unique_keyorder), case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of {ok, _Obj} -> {ok, State}; From da7756d1fb1ff4089890ddc9ade074c189d12c1a Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Thu, 19 Jul 2018 13:46:08 +0100 Subject: [PATCH 72/75] Attempt at HTTP based bench GET --- examples/riakc_nhs_clinicals.config | 2 +- src/basho_bench_driver_nhs.erl | 34 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/examples/riakc_nhs_clinicals.config b/examples/riakc_nhs_clinicals.config index 21fe7dedd..593cbe9ec 100644 --- a/examples/riakc_nhs_clinicals.config +++ b/examples/riakc_nhs_clinicals.config @@ -15,7 +15,7 @@ %% For alwaysget operations what is: %% - the maximum number of keys per worker (max number of keys = this * concurrent) %% - whether the inserts should be in key_order -{alwaysget, {300000, 120000, skew_order}}. +{alwaysget, {400000, 120000, skew_order}}. {unique, {7000, skew_order}}. {pb_ips, [{127,0,0,1}]}. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index ab5f588c2..175c4e3be 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -167,6 +167,31 @@ run(get_pb, KeyGen, _ValueGen, State) -> {error, Reason, State} end; +run(alwaysget_http, _KeyGen, _ValueGen, State) -> + Host = inet_parse:ntoa(State#state.http_host), + Port = State#state.http_port, + Bucket = State#state.recordBucket, + AGKC = State#state.alwaysget_key_count, + case AGKC > State#state.alwaysget_perworker_minkeycount of + true -> + KeyInt = eightytwenty_keycount(AGKC), + Key = generate_uniquekey(KeyInt, State#state.rand_keyid, + State#state.alwaysget_keyorder), + URL = + io_lib:format("http://~s:~p/buckets/~s/keys/~s", + [Host, Port, Bucket, Key]), + + case get_existing(URL, State#state.http_timeout) of + ok -> + {ok, State}; + {error, Reason} -> + % not_found is not OK + {error, Reason, State} + end; + false -> + {silent, State} + end; + run(alwaysget_pb, _KeyGen, _ValueGen, State) -> % Get one of the objects with unique keys Pid = State#state.pb_pid, @@ -174,7 +199,6 @@ run(alwaysget_pb, _KeyGen, _ValueGen, State) -> AGKC = State#state.alwaysget_key_count, case AGKC > State#state.alwaysget_perworker_minkeycount of true -> - KeyInt = eightytwenty_keycount(AGKC), Key = generate_uniquekey(KeyInt, State#state.rand_keyid, State#state.alwaysget_keyorder), @@ -505,6 +529,14 @@ json_get(Url, Timeout, UsePool) -> {error, Other} end. +get_existing(Url, Timeout) -> + case ibrowse:send_req(lists:flatten(Url), [], get, [], [], Timeout) of + {ok, "200", _, _Body} -> + ok; + Other -> + {error, Other} + end. + to_binary(B) when is_binary(B) -> B; From be33ca32e2477f12738f36acda77da710227566a Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Fri, 20 Jul 2018 09:21:48 +0100 Subject: [PATCH 73/75] Add node() to key ID To distnguish between different nodes use a key id rather than random bytes. Aim is to make different nodes produce different keys - if we run basho_bench from > 1 test harness --- src/basho_bench_driver_nhs.erl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 175c4e3be..4d08f0bf2 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -54,7 +54,7 @@ singleton_pid :: pid() | undefined, unique_key_count = 1 :: non_neg_integer(), alwaysget_key_count = 1 :: non_neg_integer(), - rand_keyid = crypto:rand_bytes(4) :: binary(), + keyid :: binary(), last_forceaae = os:timestamp() :: erlang:timestamp() }). @@ -125,6 +125,9 @@ new(Id) -> basho_bench_config:get(alwaysget, {1, 1, key_order}), {DocSize, DocKeyOrder} = basho_bench_config:get(unique, {8000, key_order}), + + KeyIDint = erlang:phash2(Id) bxor erlang:phash2(node()), + ?INFO("Using Node ID ~w to generate ID ~w\n", [node(), KeyIDint]), case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of {ok, Pid} -> @@ -146,7 +149,8 @@ new(Id) -> alwaysget_perworker_minkeycount = AGMinKC, alwaysget_keyorder = AGKeyOrder, unique_size = DocSize, - unique_keyorder = DocKeyOrder + unique_keyorder = DocKeyOrder, + keyid = <> }}; {error, Reason2} -> ?FAIL_MSG("Failed to connect riakc_pb_socket to ~p port ~p: ~p\n", @@ -175,7 +179,7 @@ run(alwaysget_http, _KeyGen, _ValueGen, State) -> case AGKC > State#state.alwaysget_perworker_minkeycount of true -> KeyInt = eightytwenty_keycount(AGKC), - Key = generate_uniquekey(KeyInt, State#state.rand_keyid, + Key = generate_uniquekey(KeyInt, State#state.keyid, State#state.alwaysget_keyorder), URL = io_lib:format("http://~s:~p/buckets/~s/keys/~s", @@ -200,7 +204,7 @@ run(alwaysget_pb, _KeyGen, _ValueGen, State) -> case AGKC > State#state.alwaysget_perworker_minkeycount of true -> KeyInt = eightytwenty_keycount(AGKC), - Key = generate_uniquekey(KeyInt, State#state.rand_keyid, + Key = generate_uniquekey(KeyInt, State#state.keyid, State#state.alwaysget_keyorder), case riakc_pb_socket:get(Pid, @@ -232,7 +236,7 @@ run(alwaysget_updatewith2i, _KeyGen, ValueGen, State) -> true -> % Expand the key count ExpansionKey = - generate_uniquekey(AGKC + 1, State#state.rand_keyid, + generate_uniquekey(AGKC + 1, State#state.keyid, State#state.alwaysget_keyorder), case {AGKC rem 1000, State#state.nominated_id} of {0, true} -> @@ -247,7 +251,7 @@ run(alwaysget_updatewith2i, _KeyGen, ValueGen, State) -> false -> % update an existing key ExistingKey = - generate_uniquekey(KeyInt, State#state.rand_keyid, + generate_uniquekey(KeyInt, State#state.keyid, State#state.alwaysget_keyorder), {ok, Robj} = riakc_pb_socket:get(Pid, @@ -307,7 +311,7 @@ run(put_unique, _KeyGen, _ValueGen, State) -> UKC = State#state.unique_key_count, Key = generate_uniquekey(UKC, - State#state.rand_keyid, + State#state.keyid, State#state.unique_keyorder), Value = non_compressible_value(State#state.unique_size), @@ -331,7 +335,7 @@ run(get_unique, _KeyGen, _ValueGen, State) -> Bucket = State#state.documentBucket, UKC = State#state.unique_key_count, Key = generate_uniquekey(random:uniform(UKC), - State#state.rand_keyid, + State#state.keyid, State#state.unique_keyorder), case riakc_pb_socket:get(Pid, Bucket, Key, State#state.pb_timeout) of {ok, _Obj} -> From 0f426229442959d0e5341dbe82db5e4c93a437a5 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Fri, 20 Jul 2018 09:43:11 +0100 Subject: [PATCH 74/75] Allow admin override of node name --- examples/riakc_nhs.config | 2 ++ examples/riakc_nhs_clinicals.config | 2 ++ src/basho_bench_driver_nhs.erl | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/riakc_nhs.config b/examples/riakc_nhs.config index 79c193706..4a78dd7d9 100644 --- a/examples/riakc_nhs.config +++ b/examples/riakc_nhs.config @@ -3,6 +3,8 @@ {duration, 1440}. {report_interval, 10}. +{node_name, testnode1}. + {concurrent, 100}. {driver, basho_bench_driver_nhs}. diff --git a/examples/riakc_nhs_clinicals.config b/examples/riakc_nhs_clinicals.config index 593cbe9ec..075553798 100644 --- a/examples/riakc_nhs_clinicals.config +++ b/examples/riakc_nhs_clinicals.config @@ -3,6 +3,8 @@ {duration, 1440}. {report_interval, 10}. +{node_name, testnode1}. + {concurrent, 100}. {driver, basho_bench_driver_nhs}. diff --git a/src/basho_bench_driver_nhs.erl b/src/basho_bench_driver_nhs.erl index 4d08f0bf2..9c3aa2c54 100644 --- a/src/basho_bench_driver_nhs.erl +++ b/src/basho_bench_driver_nhs.erl @@ -126,7 +126,9 @@ new(Id) -> {DocSize, DocKeyOrder} = basho_bench_config:get(unique, {8000, key_order}), - KeyIDint = erlang:phash2(Id) bxor erlang:phash2(node()), + NodeID = basho_bench_config:get(node_name, node()), + + KeyIDint = erlang:phash2(Id) bxor erlang:phash2(NodeID), ?INFO("Using Node ID ~w to generate ID ~w\n", [node(), KeyIDint]), case riakc_pb_socket:start_link(PBTargetIp, PBTargetPort) of From 57e133a0c2369e53d332e4695f9e9e6e3a7053ea Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Fri, 16 Nov 2018 17:01:39 +0000 Subject: [PATCH 75/75] New NHS load test General load test. Sort of somewhere between the demands of all three functional domain clusters. Also included is a passive version, designed to be a relatively unchallenging passive-site load (for providing load under cluster admin tests). --- examples/riakc_nhs_general.config | 48 +++++++++++++++++++++++++++++++ examples/riakc_nhs_passive.config | 48 +++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 examples/riakc_nhs_general.config create mode 100644 examples/riakc_nhs_passive.config diff --git a/examples/riakc_nhs_general.config b/examples/riakc_nhs_general.config new file mode 100644 index 000000000..a9bfb02f3 --- /dev/null +++ b/examples/riakc_nhs_general.config @@ -0,0 +1,48 @@ +{mode, max}. + +{duration, 1440}. + +{report_interval, 10}. + +{node_name, testnode1}. + +{concurrent, 100}. + +{driver, basho_bench_driver_nhs}. + +%% Ignored by alwaysget and unique operations +{key_generator, {eightytwenty_int, 100000000}}. + +{value_generator, {semi_compressible, 8000, 2000, 10, 0.2}}. + +%% For alwaysget operations what is: +%% - the maximum number of keys per worker (max number of keys = this * concurrent) +%% - whether the inserts should be in key_order +{alwaysget, {240000, 100000, skew_order}}. +{unique, {8000, skew_order}}. + +{pb_ips, [{127,0,0,1}]}. +{http_ips, [{127,0,0,1}]}. + +{riakc_pb_replies, 1}. + +{operations, [{alwaysget_pb, 651}, {alwaysget_updatewith2i, 120}, + {put_unique, 95}, {get_unique, 130}, + {postcodequery_http, 3}, {dobquery_http, 1}]}. + +%% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). +%% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. +{pb_connect_options, [{auto_reconnect, true}]}. + +%% Overrides for the PB client's default 60 second timeout, on a +%% per-type-of-operation basis. All timeout units are specified in +%% milliseconds. The pb_timeout_general config item provides a +%% default timeout if the read/write/listkeys/mapreduce timeout is not +%% specified. + +{pb_timeout_general, 60000}. +{pb_timeout_read, 10000}. +{pb_timeout_write, 10000}. +{pb_timeout_listkeys, 60000}. +%% The general timeout will be used because this specific item is commented: +%% {pb_timeout_mapreduce, 50000}. \ No newline at end of file diff --git a/examples/riakc_nhs_passive.config b/examples/riakc_nhs_passive.config new file mode 100644 index 000000000..469898be8 --- /dev/null +++ b/examples/riakc_nhs_passive.config @@ -0,0 +1,48 @@ +{mode, {rate, 10}}. + +{duration, 1440}. + +{report_interval, 10}. + +{node_name, testnode1}. + +{concurrent, 10}. + +{driver, basho_bench_driver_nhs}. + +%% Ignored by alwaysget and unique operations +{key_generator, {eightytwenty_int, 100000000}}. + +{value_generator, {semi_compressible, 8000, 2000, 10, 0.2}}. + +%% For alwaysget operations what is: +%% - the maximum number of keys per worker (max number of keys = this * concurrent) +%% - whether the inserts should be in key_order +{alwaysget, {240000, 100000, skew_order}}. +{unique, {8000, skew_order}}. + +{pb_ips, [{127,0,0,1}]}. +{http_ips, [{127,0,0,1}]}. + +{riakc_pb_replies, 1}. + +{operations, [{alwaysget_pb, 4}, {alwaysget_updatewith2i, 600}, + {put_unique, 390}, {get_unique, 4}, + {postcodequery_http, 1}, {dobquery_http, 1}]}. + +%% Use {auto_reconnect, false} to get "old" behavior (prior to April 2013). +%% See deps/riakc/src/riakc_pb_socket.erl for all valid socket options. +{pb_connect_options, [{auto_reconnect, true}]}. + +%% Overrides for the PB client's default 60 second timeout, on a +%% per-type-of-operation basis. All timeout units are specified in +%% milliseconds. The pb_timeout_general config item provides a +%% default timeout if the read/write/listkeys/mapreduce timeout is not +%% specified. + +{pb_timeout_general, 60000}. +{pb_timeout_read, 10000}. +{pb_timeout_write, 10000}. +{pb_timeout_listkeys, 60000}. +%% The general timeout will be used because this specific item is commented: +%% {pb_timeout_mapreduce, 50000}. \ No newline at end of file