anchor.diff:      %% start registration
       lists:foreach(fun({Node, FromName, _ToName}) ->
           Pids = maps:get(Node, PidsMap),
  -        rpc:cast(Node, ?MODULE, register_on_node, [CollectorPid, FromName, Pids])
  +        rpc:cast(Node, ?MODULE, register_on_node, [CollectorPid, WorkersPerNode, FromName, Pids])
       end, NodesInfo),
   
       %% wait
  
positive.code:     start/0,
      start_processes/1,
      process_loop/0,
      register_on_node/3,
      do_register_on_node/2,
      unregister_on_node/3,
      do_unregister_on_node/2,
      wait_registration_propagation/1,
      wait_unregistration_propagation/0
  ]).
  
negative.code:     %% stop node
      init:stop().
  
  register_on_node(CollectorPid, WorkersPerNode, FromName, Pids) ->
      %% split pids in workers
      PidsPerNode = round(length(Pids) / WorkersPerNode),
      {WorkerInfo, []} = lists:foldl(fun(I, {WInfo, RPids}) ->
          {WorkerPids, RestOfPids} = case I of
              WorkersPerNode ->
                  %% last in the loop, get remaining pids
                  {RPids, []};
              _ ->
                  %% get portion of pids
                  lists:split(PidsPerNode, RPids)
          end,
          WorkerFromName = FromName + (PidsPerNode * (I - 1)),
          {[{WorkerFromName, WorkerPids} | WInfo], RestOfPids}
      end, {[], Pids}, lists:seq(1, WorkersPerNode)),
      %% start measure, spawn time is irrelevant
      StartAt = os:system_time(millisecond),
      %% spawn workers
      ReplyPid = self(),
      lists:foreach(fun({WorkerFromName, WorkerPids}) ->
          spawn(fun() ->
              worker_register_on_node(WorkerFromName, WorkerPids),
              ReplyPid ! done
          end)
      end, WorkerInfo),
      %% wait
      wait_register_on_node(CollectorPid, StartAt, WorkersPerNode).
  
  worker_register_on_node(_Name, []) -> ok;
  worker_register_on_node(Name, [Pid | PidsTail]) ->
      ok = syn:register(Name, Pid),
      worker_register_on_node(Name + 1, PidsTail).
  
  wait_register_on_node(CollectorPid, StartAt, 0) ->
      Time = (os:system_time(millisecond) - StartAt) / 1000,
      io:format("----> Registered on node ~p on ~p secs.~n", [node(), Time]),
      CollectorPid ! {done, node(), Time};
  wait_register_on_node(CollectorPid, StartAt, WorkersRemainingCount) ->
      receive
          done -> wait_register_on_node(CollectorPid, StartAt, WorkersRemainingCount - 1)
      end.
  
  unregister_on_node(CollectorPid, WorkersPerNode, FromName, ToName) ->
      %% split pids in workers
      ProcessesPerNode = ToName - FromName + 1,
      ProcessesPerWorker = round(ProcessesPerNode / WorkersPerNode),
      WorkerInfo = lists:foldl(fun(I, Acc) ->
          {WorkerFromName, WorkerToName} = case I of
              WorkersPerNode ->
                  %% last in the loop
                  {FromName + (I - 1) * ProcessesPerWorker, ToName};
  
              _ ->
                  {FromName + (I - 1) * ProcessesPerWorker, FromName + I * ProcessesPerWorker - 1}
          end,
          [{WorkerFromName, WorkerToName} | Acc]
      end, [], lists:seq(1, WorkersPerNode)),
      %% start measure, spawn time is irrelevant
      StartAt = os:system_time(millisecond),
      %% spawn workers
      ReplyPid = self(),
      lists:foreach(fun({WorkerFromName, WorkerToName}) ->
          spawn(fun() ->
              worker_unregister_on_node(WorkerFromName, WorkerToName),
              ReplyPid ! done
          end)
      end, WorkerInfo),
      %% wait
      wait_unregister_on_node(CollectorPid, StartAt, WorkersPerNode).
  
  worker_unregister_on_node(FromName, ToName) when FromName > ToName -> ok;
  worker_unregister_on_node(Name, ToName) ->
      ok = syn:unregister(Name),
      worker_unregister_on_node(Name + 1, ToName).
  
  wait_unregister_on_node(CollectorPid, StartAt, 0) ->
      Time = (os:system_time(millisecond) - StartAt) / 1000,
      io:format("----> Unregistered on node ~p on ~p secs.~n", [node(), Time]),
      CollectorPid ! {done, node(), Time};
  wait_unregister_on_node(CollectorPid, StartAt, WorkersRemainingCount) ->
      receive
          done -> wait_unregister_on_node(CollectorPid, StartAt, WorkersRemainingCount - 1)
      end.
  
  start_processes(Count) ->
      start_processes(Count, []).
  