nickva commented on PR #5:
URL: https://github.com/apache/couchdb-folsom/pull/5#issuecomment-1590338151
Based on local benchmarking with this script which concurrently updates a
bunch of histograms:
```erlang
-module(upstats).
-export([go/0, go/1, go/2]).
go() ->
go(1000, 10000).
go(N) ->
go(N, 10000).
go(N, X) ->
T0 = erlang:monotonic_time(),
Workers = [spawn_monitor(fun() ->
rand:seed(default, os:timestamp()),
upstat(X)
end) || _ <- lists:seq(1, N)],
{_Pids, Refs} = lists:unzip(Workers),
WorkersSet = sets:from_list(Refs, [{version,2}]),
ok = wait_workers(WorkersSet),
Dt = erlang:monotonic_time() - T0,
erlang:convert_time_unit(Dt, native, millisecond).
upstat(0) ->
ok;
upstat(Times) ->
Hist = case rand:uniform(5) of
1 -> [couchdb, request_time];
2 -> [couchdb, dbinfo];
3 -> [couchdb, httpd, bulk_docs];
4 -> [fsync, time];
5 -> [couchdb, db_open_time]
end,
couch_stats:update_histogram(Hist, 100),
upstat(Times - 1).
wait_workers(Workers) when is_map(Workers) ->
case sets:size(Workers) of
0 ->
ok;
_ ->
receive
{'DOWN', Ref, process, _, normal} ->
Workers1 = sets:del_element(Ref, Workers),
wait_workers(Workers1);
{'DOWN', Ref, process, _, Err} ->
Workers1 = sets:del_element(Ref, Workers),
io:format("~n worker ~p crashed: ~p~n", [Ref, Err]),
wait_workers(Workers1)
end
end.
```
Didn't notice any measurable improvement. There seems to be a slightly less
number of collisions however overall time to perform the updates is about the
same. So it doesn't seem worth it.
Leaving it here mostly as a historical experiment for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]