Skip to content

Commit

Permalink
Hibernate idle transport workers
Browse files Browse the repository at this point in the history
Summary: If a transport worker has no active jobs, then instruct it to hibernate.

Differential Revision: D60191351

fbshipit-source-id: 2f2112f5693b951b34e3d49527891ef8e9b03266
  • Loading branch information
hsun324 authored and facebook-github-bot committed Jul 24, 2024
1 parent ec5d164 commit 07179eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wa_raft_transport_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down

0 comments on commit 07179eb

Please sign in to comment.