Permalink
Browse files

Perf experiment, spawn the remote FSM for forwarded puts.

  • Loading branch information...
1 parent 3da7cfd commit 0048f75c301796bcf3dc637a530c44fa201ba123 @jonmeredith jonmeredith committed Sep 3, 2012
Showing with 12 additions and 8 deletions.
  1. +12 −8 src/riak_kv_put_fsm.erl
View
@@ -32,7 +32,7 @@
-behaviour(gen_fsm).
-define(DEFAULT_OPTS, [{returnbody, false}, {update_last_modified, true}]).
--export([start/6,start/7]).
+-export([start/3, start/6,start/7]).
-export([start_link/3,start_link/6,start_link/7]).
-ifdef(TEST).
-export([test_link/4]).
@@ -106,6 +106,9 @@
%% Public API
%% ===================================================================
+start(From, Object, PutOptions) ->
+ gen_fsm:start(?MODULE, [From, Object, PutOptions], []).
+
%% In place only for backwards compatibility
start(ReqId,RObj,W,DW,Timeout,ResultPid) ->
start_link(ReqId,RObj,W,DW,Timeout,ResultPid,[]).
@@ -205,16 +208,17 @@ prepare(timeout, StateData0 = #state{from = From, robj = RObj,
%% This node is not in the preference list
%% forward on to the first node
[{{_Idx, CoordNode},_Type}|_] = Preflist2,
- Timeout = get_option(timeout, Options, ?DEFAULT_TIMEOUT),
+ _Timeout = get_option(timeout, Options, ?DEFAULT_TIMEOUT),
?DTRACE(?C_PUT_FSM_PREPARE, [1],
["prepare", atom2list(CoordNode)]),
- case rpc:call(CoordNode,riak_kv_put_fsm_sup,start_put_fsm,[CoordNode,[From,RObj,Options]],Timeout) of
- {ok, _Pid} ->
- ?DTRACE(?C_PUT_FSM_PREPARE, [2],
+ try
+ proc_lib:spawn(CoordNode,riak_kv_put_fsm,start,[From,RObj,Options]),
+ ?DTRACE(?C_PUT_FSM_PREPARE, [2],
["prepare", atom2list(CoordNode)]),
- riak_kv_stat:update(coord_redir),
- {stop, normal, StateData0};
- {_, Reason} -> % {error,_} or {badrpc,_}
+ riak_kv_stat:update(coord_redir),
+ {stop, normal, StateData0}
+ catch
+ _:Reason ->
?DTRACE(?C_PUT_FSM_PREPARE, [-2],
["prepare", dtrace_errstr(Reason)]),
lager:error("Unable to forward put for ~p to ~p - ~p\n",

0 comments on commit 0048f75

Please sign in to comment.