Skip to content

Commit

Permalink
Merge pull request #935 from basho/bugfix/jnd/everybody-to-the-limit
Browse files Browse the repository at this point in the history
Fix limit checks in riak_kv_env for R16B02-basho5
  • Loading branch information
joedevivo committed May 9, 2014
2 parents e66f3ff + 12e18b7 commit a547c7e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ ebin
dialyzer_unhandled_warnings
dialyzer_warnings
tags
erln8.config
77 changes: 35 additions & 42 deletions src/riak_kv_env.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
-export([doc_env/0]).

-define(LINUX_PARAMS, [
{"vm.swappiness", 0, gte},
{"vm.swappiness", 0, gte},
{"net.core.wmem_default", 8388608, lte},
{"net.core.rmem_default", 8388608, lte},
{"net.core.wmem_max", 8388608, lte},
Expand Down Expand Up @@ -53,7 +53,7 @@ doc_env() ->
[];
{unix, sunos} ->
[];
_ ->
_ ->
[{warn, "Unknown OS type, no platform specific info", []}]
end,
lists:map(fun({F, Fmt, Args}) ->
Expand All @@ -72,34 +72,34 @@ doc_env() ->
check_ulimits() ->
%% file ulimit
FileLimit0 = string:strip(os:cmd("ulimit -n"), right, $\n),
FLMsg = case FileLimit0 of
"unlimited" ->
FLMsg = case FileLimit0 of
"unlimited" ->
%% check the OS limit;
OSLimit = case os:type() of
OSLimit = case os:type() of
{unix, linux} ->
string:strip(os:cmd("sysctl -n fs.file-max"),
string:strip(os:cmd("sysctl -n fs.file-max"),
right, $\n);
_ -> unknown
end,
case OSLimit of
unknown ->
unknown ->
{warn, "Open file limit unlimited but actual limit "
++ "could not be ascertained", []};
_ ->
_ ->
test_file_limit(OSLimit)
end;
_ ->
_ ->
test_file_limit(FileLimit0)
end,
end,
CoreLimit0 = string:strip(os:cmd("ulimit -c"), right, $\n),
CLMsg = case CoreLimit0 of
"unlimited" ->
CLMsg = case CoreLimit0 of
"unlimited" ->
{info, "No core size limit", []};
_ ->
CoreLimit = list_to_integer(CoreLimit0),
case CoreLimit == 0 of
case CoreLimit == 0 of
true ->
{warn, "Cores are disabled, this may "
{warn, "Cores are disabled, this may "
++ "hinder debugging", []};
false ->
{info, "Core size limit: ~p", [CoreLimit]}
Expand All @@ -111,19 +111,19 @@ check_ulimits() ->
test_file_limit(FileLimit0) ->
FileLimit = (catch list_to_integer(FileLimit0)),
case FileLimit of
{'EXIT', {badarg,_}} ->
{'EXIT', {badarg,_}} ->
{warn, "Open file limit was read as non-integer string: ~s",
[FileLimit0]};
_ ->
case FileLimit < 4096 of

_ ->
case FileLimit < 4096 of
true ->
{warn, "Open file limit of ~p is low, at least "
++ "4096 is recommended", [FileLimit]};
false ->
false ->
{info, "Open file limit: ~p", [FileLimit]}
end
end.
end.

%% @private
check_erlang_limits() ->
Expand All @@ -136,24 +136,17 @@ check_erlang_limits() ->
{info,"Erlang process limit: ~p", [PL2]}
end,
%% ports
PortLimit = case os:getenv("ERL_MAX_PORTS") of
false -> 1024;
PL -> list_to_integer(PL)
end,
PortLimit = erlang:system_info(port_limit),
PortMsg = case PortLimit < 64000 of
true ->
%% needs to be revisited for R16+
{warn, "Erlang ports limit of ~p is low, at least "
"64000 is recommended", [PortLimit]};
false ->
{info, "Erlang ports limit: ~p", [PortLimit]}
end,

%% ets tables
ETSLimit = case os:getenv("ERL_MAX_ETS_TABLES") of
false -> 1400;
Limit -> list_to_integer(Limit)
end,
ETSLimit = erlang:system_info(ets_limit),
ETSMsg = case ETSLimit < 256000 of
true ->
{warn,"ETS table count limit of ~p is low, at least "
Expand Down Expand Up @@ -183,7 +176,7 @@ check_erlang_limits() ->
{warn, "Running ~p schedulers for ~p cores, "
"these should match", [Schedulers, Cores]};
false ->
{info, "Schedulers: ~p for ~p cores",
{info, "Schedulers: ~p for ~p cores",
[Schedulers, Cores]}
end,
[PLMsg, PortMsg, ETSMsg, TPSMsg, GCMsg, SMsg].
Expand All @@ -198,32 +191,32 @@ check_sysctls(Checklist) ->
lte -> Actual >= Val;
eq -> Actual == Val
end,
case Good of
case Good of
true ->
{info , "sysctl ~s is ~p ~s ~p)",
[Param, Actual,
direction_to_word(Direction),
{info , "sysctl ~s is ~p ~s ~p)",
[Param, Actual,
direction_to_word(Direction),
Val]};
false ->
{warn, "sysctl ~s is ~p, should be ~s~p)",
[Param, Actual,
direction_to_word2(Direction),
false ->
{warn, "sysctl ~s is ~p, should be ~s~p)",
[Param, Actual,
direction_to_word2(Direction),
Val]}
end
end,
lists:map(Fn, Checklist).

%% @private
direction_to_word(Direction) ->
case Direction of
case Direction of
gte -> "greater than or equal to";
lte -> "lesser than or equal to";
eq -> "equal to"
end.

%% @private
direction_to_word2(Direction) ->
case Direction of
case Direction of
gte -> "no more than ";
lte -> "at least ";
eq -> ""
Expand Down

0 comments on commit a547c7e

Please sign in to comment.