Hi, guys,
I found  that the problem only appeared in some special computers. For
example the problem can only be reproduced in my old MacBook(2007, MacOSX
Lion) and Intel Atom computer(Intel(R) Atom(TM) CPU N2800   @ 1.86GHz,
Ubuntu 12.04). I cannot reproduce it on a Desktop PC, which is Intel(R)
Core(TM)2 Duo CPU     E7500  @ 2.93GHz, Ubuntu 13.04.


my test code:
test_parallel_put() ->
      folsom:start(),
      folsom_metrics:new_histogram(put_metric),

      B = <<"bigdata">>,
      F = "/tmp/sss.mp4", %% a 384MB size file
      [spawn_put_worker(B, F, S) || S <- lists:seq(1, 10)].

spawn_put_worker(B, F, S) ->
      spawn(fun() ->
          {ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 10017),
          {ok, IoDevice} = file:open(F, [read, binary]),
          [do_one_put(IoDevice, Pid, B, S, I) || I <- lists:seq(1, 100)]
      end).

  do_one_put(IoDevice, Pid, B, S, I) ->
      K = list_to_binary(integer_to_list(S * 100 + I)),
      {ok, BinData} = file:pread(IoDevice, S*100 + I, 2097152),
      O = riakc_obj:new(B, K, BinData),
      {Elapse,Res} = timer:tc(folsom_metrics,
                              histogram_timed_update,
                              [put_metric, riakc_pb_socket, put, [Pid, O]]),
      io:format("Pid: ~p, sz: ~p, time put: ~p, OK~n", [Pid, size(BinData),
Elapse/1000.0]).


--------------------------------------


test_parallel_get() ->
      folsom:start(),
      folsom_metrics:new_histogram(get_metric),

      B = <<"bigdata">>,
      [spawn_get_worker(B, S) || S <- lists:seq(1, 10)].

spawn_get_worker(B, S) ->
      spawn(fun() ->
          {ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 10017),
          io:format("riakc: ~p~n", [Pid]),
          [do_one_get(Pid, B, S, I) || I <- lists:seq(1, 100)]
      end).

  do_one_get(Pid, B, S, I) ->
      K = list_to_binary(integer_to_list(S * 100 + I)),
      {Elapse,Res} = timer:tc(folsom_metrics,
                              histogram_timed_update,
                              [get_metric, riakc_pb_socket, get, [Pid, B,
K]]),
      case Res of
      {ok, O} ->
          BinData = riakc_obj:get_value(O),
          io:format("~p) Pid: ~p, sz: ~p, time get: ~p, OK~n",
                    [I, Pid, size(BinData), Elapse/1000.0]);
      {error, Reason} ->
          io:format("~p) Pid: ~p(is alive: ~p), time get: ~p, Error Rason
-----> ~p~n",
                    [I, Pid, is_process_alive(Pid), Elapse/1000.0, Reason])
      end.


the tests show that parallel-put always work well, in any case. However,
parallel-get has some problem in some platform.
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to