iilyak commented on code in PR #4151:
URL: https://github.com/apache/couchdb/pull/4151#discussion_r950239487


##########
src/couch_replicator/test/eunit/couch_replicator_many_leaves_tests.erl:
##########
@@ -251,7 +169,33 @@ add_attachments(SourceDb, NumAtts, [{DocId, NumConflicts} 
| Rest]) ->
         [],
         SourceDocs
     ),
-    {ok, UpdateResults} = couch_db:update_docs(SourceDb, NewDocs, []),
+    {ok, UpdateResults} = fabric:update_docs(SourceDb, NewDocs, [?ADMIN_CTX]),
     NewRevs = [R || {ok, R} <- UpdateResults],
     ?assertEqual(length(NewDocs), length(NewRevs)),
     add_attachments(SourceDb, NumAtts, Rest).
+
+make_att(Id, Pos, Rev, Size) ->
+    AttData = crypto:strong_rand_bytes(Size),

Review Comment:
   I don't have numbers, but I feel that strong_rand_bytes is slow (however it 
is in C so I could be wrong).
   
   Do we really need it to be random?
   
   ```
   random(N) ->
      list_to_binary(lists:map(fun(_) -> rand:uniform(255) end, lists:seq(1, 
N))).
      
   bytes(N) ->
      binary:copy(<<1>>, N).
   
   % return correct number of bytes only if N is power of 2
   power_of_two(N) ->
        binary:copy(<<1,2,3,4,5,6,7,8>>, N bsr 3).
   ```
   
   While looking for benchmarks of `crypto:strong_rand_bytes/1` I came across 
an interesting post (require otp25) 
https://www.erlang.org/blog/faster-rand/#measurement-results



-- 
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]

Reply via email to