From 07179eb38ee11cd6558f8d5f913e5441c1e244fb Mon Sep 17 00:00:00 2001 From: Henry Sun Date: Wed, 24 Jul 2024 14:15:16 -0700 Subject: [PATCH] Hibernate idle transport workers Summary: If a transport worker has no active jobs, then instruct it to hibernate. Differential Revision: D60191351 fbshipit-source-id: 2f2112f5693b951b34e3d49527891ef8e9b03266 --- src/wa_raft_transport_worker.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wa_raft_transport_worker.erl b/src/wa_raft_transport_worker.erl index 675590f..feeac9e 100644 --- a/src/wa_raft_transport_worker.erl +++ b/src/wa_raft_transport_worker.erl @@ -100,10 +100,10 @@ handle_cast(Request, #state{number = Number} = State) -> -spec handle_info(Info :: term(), State :: state()) -> {noreply, NewState :: state()} - | {noreply, NewState :: state(), Timeout :: timeout()}. + | {noreply, NewState :: state(), Timeout :: timeout() | hibernate}. handle_info(timeout, #state{table = Table, marker = undefined} = State) -> case ets:first(Table) of - '$end_of_table' -> {noreply, State}; % table is empty so wait until there is work + '$end_of_table' -> {noreply, State, hibernate}; % table is empty so wait until there is work _FirstKey -> {noreply, State#state{marker = 0}, ?CONTINUE_TIMEOUT} % 0 compares smaller than any ref end; handle_info(timeout, #state{number = Number, table = Table, states = States, marker = Marker} = State) ->