From 8b94a527f933b4a1c17fbb0d83f20ec97ce525aa Mon Sep 17 00:00:00 2001 From: benjaminplee Date: Wed, 19 Nov 2014 19:26:54 +0000 Subject: [PATCH] Removed speculative sizing and enforced common max Difference between speculative and "real" size was no longer material to the algorithm. Used macro to enforce consistent usage of ceiling for pipeline. --- src/ibrowse_lb.erl | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ibrowse_lb.erl b/src/ibrowse_lb.erl index 3c17691..1e644eb 100644 --- a/src/ibrowse_lb.erl +++ b/src/ibrowse_lb.erl @@ -38,6 +38,8 @@ max_pipeline_size, proc_state}). +-define(PIPELINE_MAX, 99999). + -include("ibrowse.hrl"). %%==================================================================== @@ -75,11 +77,10 @@ report_connection_down(Tid) -> catch ets:delete(Tid, self()). report_request_underway(Tid) -> - catch ets:update_counter(Tid, self(), {2, 1, 9999, 9999}). + catch ets:update_counter(Tid, self(), {2, 1, ?PIPELINE_MAX, ?PIPELINE_MAX}). report_request_complete(Tid) -> - catch ets:update_counter(Tid, self(), {2, -1, 0, 0}), - catch ets:update_counter(Tid, self(), {3, -1, 0, 0}). + catch ets:update_counter(Tid, self(), {2, -1, 0, 0}). %%==================================================================== %% Server functions @@ -121,7 +122,7 @@ handle_call(stop, _From, #state{ets_tid = undefined} = State) -> gen_server:reply(_From, ok), {stop, normal, State}; handle_call(stop, _From, #state{ets_tid = Tid} = State) -> - ets:foldl(fun({Pid, _, _}, Acc) -> + ets:foldl(fun({Pid, _}, Acc) -> ibrowse_http_client:stop(Pid), Acc end, [], Tid), @@ -171,10 +172,8 @@ handle_info({trace, Bool}, #state{ets_tid = undefined} = State) -> put(my_trace_flag, Bool), {noreply, State}; handle_info({trace, Bool}, #state{ets_tid = Tid} = State) -> - ets:foldl(fun({{_, Pid}, _}, Acc) when is_pid(Pid) -> + ets:foldl(fun({Pid, _}, Acc) when is_pid(Pid) -> catch Pid ! {trace, Bool}, - Acc; - (_, Acc) -> Acc end, undefined, Tid), put(my_trace_flag, Bool), @@ -224,8 +223,7 @@ find_best_connection('$end_of_table', _, _) -> {error, retry_later}; find_best_connection(Pid, Tid, Max_pipe) -> case ets:lookup(Tid, Pid) of - [{Pid, Cur_sz, Speculative_sz}] when Cur_sz < Max_pipe, - Speculative_sz < Max_pipe -> + [{Pid, Cur_sz}] when Cur_sz < Max_pipe -> case record_request_for_connection(Tid, Pid) of {'EXIT', _} -> %% The selected process has shutdown @@ -248,7 +246,7 @@ num_current_connections(Tid) -> catch ets:info(Tid, size). record_new_connection(Tid, Pid) -> - catch ets:insert(Tid, {Pid, 0, 0}). + catch ets:insert(Tid, {Pid, 0}). record_request_for_connection(Tid, Pid) -> - catch ets:update_counter(Tid, Pid, {3, 1, 9999999, 9999999}). + catch ets:update_counter(Tid, Pid, {2, 1, ?PIPELINE_MAX, ?PIPELINE_MAX}).