Whitespace fixes (s/tab/space/g) and added two new configuration settings
from the 1.5.0 release. Checkpoint every second, dump stats every 30 sec.
This commit is contained in:
parent
85fadeec70
commit
3543b42df8
2 changed files with 61 additions and 56 deletions
|
@ -55,7 +55,7 @@
|
||||||
-record(state, {conn :: wterl:connection(),
|
-record(state, {conn :: wterl:connection(),
|
||||||
table :: string(),
|
table :: string(),
|
||||||
session :: wterl:session(),
|
session :: wterl:session(),
|
||||||
cursors :: ets:tid(),
|
cursors :: ets:tid(),
|
||||||
partition :: integer()}).
|
partition :: integer()}).
|
||||||
|
|
||||||
-type state() :: #state{}.
|
-type state() :: #state{}.
|
||||||
|
@ -109,18 +109,20 @@ start(Partition, Config) ->
|
||||||
RingSize -> RingSize * 2
|
RingSize -> RingSize * 2
|
||||||
end,
|
end,
|
||||||
ConnectionOpts = [Config,
|
ConnectionOpts = [Config,
|
||||||
{create, true},
|
{create, true},
|
||||||
{logging, true},
|
{sync, false},
|
||||||
{transactional, true},
|
{logging, true},
|
||||||
{session_max, SessionMax},
|
{transactional, true},
|
||||||
{cache_size, size_cache(Config)},
|
{session_max, SessionMax},
|
||||||
{sync, false}
|
{cache_size, size_cache(Config)},
|
||||||
%% {verbose,
|
{checkpoint, [{wait, 1}]}, % sec
|
||||||
%% ["block", "shared_cache", "ckpt", "evict",
|
{statistics_log, [{wait, 30}]} % sec
|
||||||
%% "evictserver", "fileops", "hazard", "lsm",
|
%% {verbose,
|
||||||
%% "mutex", "read", "readserver", "reconcile",
|
%% ["block", "shared_cache", "ckpt", "evict",
|
||||||
%% "salvage", "verify", "write"]}
|
%% "evictserver", "fileops", "hazard", "lsm",
|
||||||
],
|
%% "mutex", "read", "readserver", "reconcile",
|
||||||
|
%% "salvage", "verify", "write"]}
|
||||||
|
],
|
||||||
case wterl_conn:open(DataRoot, ConnectionOpts) of
|
case wterl_conn:open(DataRoot, ConnectionOpts) of
|
||||||
{ok, ConnRef} ->
|
{ok, ConnRef} ->
|
||||||
Table = "lsm:wt" ++ integer_to_list(Partition),
|
Table = "lsm:wt" ++ integer_to_list(Partition),
|
||||||
|
@ -152,7 +154,7 @@ stop(#state{conn=ConnRef, session=SRef, cursors=undefined}) ->
|
||||||
wterl_conn:close(ConnRef);
|
wterl_conn:close(ConnRef);
|
||||||
stop(#state{cursors=Cursors}=State) ->
|
stop(#state{cursors=Cursors}=State) ->
|
||||||
ets:foldl(fun({_Table, Cursor}, _) ->
|
ets:foldl(fun({_Table, Cursor}, _) ->
|
||||||
ok = wterl:cursor_close(Cursor)
|
ok = wterl:cursor_close(Cursor)
|
||||||
end, true, Cursors),
|
end, true, Cursors),
|
||||||
ets:delete(Cursors),
|
ets:delete(Cursors),
|
||||||
stop(State#state{cursors=undefined}).
|
stop(State#state{cursors=undefined}).
|
||||||
|
@ -353,12 +355,12 @@ shared_cursor(SRef, Table, #state{cursors=undefined}=State) ->
|
||||||
shared_cursor(SRef, Table, State#state{cursors=Cursors});
|
shared_cursor(SRef, Table, State#state{cursors=Cursors});
|
||||||
shared_cursor(SRef, Table, #state{cursors=Cursors}=State) ->
|
shared_cursor(SRef, Table, #state{cursors=Cursors}=State) ->
|
||||||
case ets:lookup(Cursors, Table) of
|
case ets:lookup(Cursors, Table) of
|
||||||
[{Table, Cursor}] ->
|
[{Table, Cursor}] ->
|
||||||
{Cursor, State};
|
{Cursor, State};
|
||||||
_ ->
|
_ ->
|
||||||
Cursor = wterl:cursor_open(SRef, Table),
|
Cursor = wterl:cursor_open(SRef, Table),
|
||||||
ets:insert(Cursors, {Table, Cursor}),
|
ets:insert(Cursors, {Table, Cursor}),
|
||||||
{Cursor, State}
|
{Cursor, State}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
@ -479,39 +481,39 @@ fetch_status(Cursor, {ok, Stat}, Acc) ->
|
||||||
|
|
||||||
size_cache(Config) ->
|
size_cache(Config) ->
|
||||||
Size =
|
Size =
|
||||||
case app_helper:get_prop_or_env(cache_size, Config, wterl) of
|
case app_helper:get_prop_or_env(cache_size, Config, wterl) of
|
||||||
{ok, Value} ->
|
{ok, Value} ->
|
||||||
Value;
|
Value;
|
||||||
undefined ->
|
undefined ->
|
||||||
RunningApps = application:which_applications(),
|
RunningApps = application:which_applications(),
|
||||||
FinalGuess =
|
FinalGuess =
|
||||||
case proplists:is_defined(sasl, RunningApps) andalso
|
case proplists:is_defined(sasl, RunningApps) andalso
|
||||||
proplists:is_defined(os_mon, RunningApps) of
|
proplists:is_defined(os_mon, RunningApps) of
|
||||||
true ->
|
true ->
|
||||||
Memory = memsup:get_system_memory_data(),
|
Memory = memsup:get_system_memory_data(),
|
||||||
TotalRAM = proplists:get_value(system_total_memory, Memory),
|
TotalRAM = proplists:get_value(system_total_memory, Memory),
|
||||||
FreeRAM = proplists:get_value(free_memory, Memory),
|
FreeRAM = proplists:get_value(free_memory, Memory),
|
||||||
UsedByBeam = proplists:get_value(total, erlang:memory()),
|
UsedByBeam = proplists:get_value(total, erlang:memory()),
|
||||||
Target = ((TotalRAM - UsedByBeam) div 3),
|
Target = ((TotalRAM - UsedByBeam) div 3),
|
||||||
FirstGuess = (Target - (Target rem (1024 * 1024))),
|
FirstGuess = (Target - (Target rem (1024 * 1024))),
|
||||||
SecondGuess =
|
SecondGuess =
|
||||||
case FirstGuess > FreeRAM of
|
case FirstGuess > FreeRAM of
|
||||||
true -> FreeRAM - (FreeRAM rem (1024 * 1024));
|
true -> FreeRAM - (FreeRAM rem (1024 * 1024));
|
||||||
_ -> FirstGuess
|
_ -> FirstGuess
|
||||||
end,
|
end,
|
||||||
case SecondGuess < 1073741824 of %% < 1GB?
|
case SecondGuess < 1073741824 of %% < 1GB?
|
||||||
true -> "1GB";
|
true -> "1GB";
|
||||||
false ->
|
false ->
|
||||||
ThirdGuess = SecondGuess div (1024 * 1024),
|
ThirdGuess = SecondGuess div (1024 * 1024),
|
||||||
integer_to_list(ThirdGuess) ++ "MB"
|
integer_to_list(ThirdGuess) ++ "MB"
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
"1GB"
|
"1GB"
|
||||||
end,
|
end,
|
||||||
application:set_env(wt, cache_size, FinalGuess),
|
application:set_env(wt, cache_size, FinalGuess),
|
||||||
lager:warning("Using best-guess cache size of ~p for WiredTiger storage backend.", [FinalGuess]),
|
lager:warning("Using best-guess cache size of ~p for WiredTiger storage backend.", [FinalGuess]),
|
||||||
FinalGuess
|
FinalGuess
|
||||||
end,
|
end,
|
||||||
Size.
|
Size.
|
||||||
|
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
|
@ -272,6 +272,7 @@ fold(Cursor, Fun, Acc, {ok, Key, Value}) ->
|
||||||
config_types() ->
|
config_types() ->
|
||||||
[{block_compressor, string},
|
[{block_compressor, string},
|
||||||
{cache_size, string},
|
{cache_size, string},
|
||||||
|
{checkpoint, map},
|
||||||
{create, bool},
|
{create, bool},
|
||||||
{direct_io, map},
|
{direct_io, map},
|
||||||
{drop, list},
|
{drop, list},
|
||||||
|
@ -293,10 +294,12 @@ config_types() ->
|
||||||
{multiprocess, bool},
|
{multiprocess, bool},
|
||||||
{name, string},
|
{name, string},
|
||||||
{session_max, integer},
|
{session_max, integer},
|
||||||
|
{statistics_log, map},
|
||||||
{sync, bool},
|
{sync, bool},
|
||||||
{target, list},
|
{target, list},
|
||||||
{transactional, bool},
|
{transactional, bool},
|
||||||
{verbose, map}].
|
{verbose, map},
|
||||||
|
{wait, integer}].
|
||||||
|
|
||||||
config_value(Key, Config, Default) ->
|
config_value(Key, Config, Default) ->
|
||||||
{Key, app_helper:get_prop_or_env(Key, Config, wterl, Default)}.
|
{Key, app_helper:get_prop_or_env(Key, Config, wterl, Default)}.
|
||||||
|
|
Loading…
Reference in a new issue