Skip to content

Commit

Permalink
Merge pull request #8 from duomark/master
Browse files Browse the repository at this point in the history
TS-1223 Slow cxy fix combining spawn and execution times
  • Loading branch information
Martin Kristiansen committed Apr 22, 2015
2 parents 13436b4 + 10d100c commit 9501438
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
20 changes: 11 additions & 9 deletions src/cxy_ctl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,19 @@ update_times(Task_Table, Task_Type, Task_Fun, Start, Spawn, Done, Check_Slowness

check_if_slow(Task_Type, Spawn_Elapsed, Exec_Elapsed) ->
{Spawn_Cma, Exec_Cma, Slow_Factor_As_Percentage} = update_cmas(Task_Type, Spawn_Elapsed, Exec_Elapsed),
case is_slow(Spawn_Elapsed, Spawn_Cma, Slow_Factor_As_Percentage)
orelse is_slow(Exec_Elapsed, Exec_Cma, Slow_Factor_As_Percentage) of

true -> is_slow;
false -> not_slow
end.
is_slow(Spawn_Elapsed, Exec_Elapsed, Spawn_Cma, Exec_Cma, Slow_Factor_As_Percentage).

%% Slow_Factor is a percentage, so 300 would be 3x the moving average.
is_slow(_, 0, _) -> false;
is_slow(Sample_Time, Moving_Avg, Slow_Factor_As_Percentage) ->
round((Sample_Time / Moving_Avg) * 100) >= Slow_Factor_As_Percentage.
%% The slow test combines the spawn time and execution time and compares
%% that to the sum of the two moving averages.
is_slow(_This_Spawn, _This_Exec, _Spawn_Cma, 0 = _Exec_Cma, _Slow_Factor_As_Percentage) -> not_slow;
is_slow( Spawn_Time, Exec_Time, Spawn_Cma, Exec_Cma, Slow_Factor_As_Percentage) ->
Cma_Time = Spawn_Cma + Exec_Cma,
Full_Time = Spawn_Time + Exec_Time,
case round((Full_Time / Cma_Time) * 100) >= Slow_Factor_As_Percentage of
false -> not_slow;
true -> is_slow
end.

update_cmas(Task_Type, Spawn_Elapsed, Exec_Elapsed) ->

Expand Down
18 changes: 9 additions & 9 deletions test/epocxy/cxy_ctl_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ check_no_timer_limits(_Config) ->
true = ?TM:init(Limits),
All_Entries = ets:tab2list(?TM),
4 = length(All_Entries),
true = lists:member({a, 15, 0, 0}, All_Entries),
true = lists:member({b, 35, 0, 0}, All_Entries),
true = lists:member({a, 15, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({b, 35, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({{cma,a}, 0, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({{cma,b}, 0, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
ok.
Expand All @@ -79,9 +79,9 @@ check_with_timer_limits(_Config) ->
true = ?TM:init(Limits),
All_Entries = ets:tab2list(?TM),
6 = length(All_Entries),
true = lists:member({a, 15, 0, 5}, All_Entries),
true = lists:member({b, 35, 0, 0}, All_Entries),
true = lists:member({c, 17, 0, 4}, All_Entries),
true = lists:member({a, 15, 0, 5, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({b, 35, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({c, 17, 0, 4, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({{cma,a}, 0, 0, 5, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({{cma,b}, 0, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({{cma,c}, 0, 0, 4, ?MAX_SLOW_FACTOR}, All_Entries),
Expand All @@ -94,10 +94,10 @@ check_atom_limits(_Config) ->
true = ?TM:init(Limits),
All_Entries = ets:tab2list(?TM),
8 = length(All_Entries),
true = lists:member({a, -1, 0, 0}, All_Entries),
true = lists:member({b, -1, 0, 5}, All_Entries),
true = lists:member({c, 0, 0, 0}, All_Entries),
true = lists:member({d, 0, 0, 7}, All_Entries),
true = lists:member({a, -1, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({b, -1, 0, 5, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({c, 0, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({d, 0, 0, 7, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({{cma,a}, 0, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({{cma,b}, 0, 0, 5, ?MAX_SLOW_FACTOR}, All_Entries),
true = lists:member({{cma,c}, 0, 0, 0, ?MAX_SLOW_FACTOR}, All_Entries),
Expand Down

0 comments on commit 9501438

Please sign in to comment.