anchor.diff:  
   
   init([]) ->
  +    _ = spawn_link(fun stale_histo_epoch_cleaner/0),
       ets:new(ns_server_system_stats, [public, named_table, set]),
       increment_counter({request_leaves, rest}, 0),
       increment_counter({request_enters, hibernate}, 0),
  
positive.code:             Stats2 = add_ets_stats(Stats),
              case ets:update_counter(ns_server_system_stats, log_counter, {2, 1, ?ETS_LOG_INTVL, 0}) of
                  0 ->
                      stats_collector:log_stats(TS, "@system", ets:tab2list(ns_server_system_stats));
                  _ ->
                      ok
              end,
  
negative.code:          just_avg_counter({S, e2e_calls}, {S, e2e_calls_rate})
       end || S <- ["unknown" | ActualServices]],
      ok.
  
  get_histo_bin(Value) when Value =< 0 -> 0;
  get_histo_bin(Value) when Value > 1000000 -> 2000000;
  get_histo_bin(Value) ->
      Step = if
                 Value < 1000 -> 100;
                 Value < 10000 -> 1000;
                 Value =< 1000000 -> 10000
             end,
      ((Value + Step - 1) div Step) * Step.
  
  
  -define(EPOCH_DURATION, 30).
  -define(EPOCH_PRESERVE_COUNT, 5).
  
  add_histo(Type, Value) ->
      BinV = get_histo_bin(Value),
      Epoch = misc:now_int() div ?EPOCH_DURATION,
      K = {h, Type, Epoch, BinV},
      increment_counter(K, 1),
      increment_counter({hg, Type, BinV}, 1).
  
  cleanup_stale_epoch_histos() ->
      NowEpoch = misc:now_int() div ?EPOCH_DURATION,
      FirstStaleEpoch = NowEpoch - ?EPOCH_PRESERVE_COUNT,
      RV = ets:select_delete(ns_server_system_stats,
                             [{{{h, '_', '$1', '_'}, '_'},
                               [{'=<', '$1', {const, FirstStaleEpoch}}],
                               [true]}]),
      RV.
  
  stale_histo_epoch_cleaner() ->
      erlang:register(system_stats_collector_stale_epoch_cleaner, self()),
      stale_histo_epoch_cleaner_loop().
  
  stale_histo_epoch_cleaner_loop() ->
      cleanup_stale_epoch_histos(),
      timer:sleep(?EPOCH_DURATION * ?EPOCH_PRESERVE_COUNT * 1100),
      stale_histo_epoch_cleaner_loop().
  