This is an automated email from the ASF dual-hosted git repository.

nickva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/main by this push:
     new 5b14b7c3e Speed up internal replicator
5b14b7c3e is described below

commit 5b14b7c3e0bfb0ef85cdabc07ea43d5854f4dfe7
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Fri Oct 16 15:43:05 2026 -0400

    Speed up internal replicator
    
    Remove quadratic lists:keyfind call from open_revs and get from O(n^2) to
    O(n). (Well probably something with a log in there based on HAMT algorithm 
for
    maps).
    
    This should allow us to use large batches above 1000 docs easily.
---
 src/mem3/src/mem3_rep.erl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mem3/src/mem3_rep.erl b/src/mem3/src/mem3_rep.erl
index 6413c72a4..55ac938cd 100644
--- a/src/mem3/src/mem3_rep.erl
+++ b/src/mem3/src/mem3_rep.erl
@@ -843,10 +843,10 @@ chunk_revs([{Id, R, A} | Revs], {Count, Chunk}, Chunks, 
Limit) ->
     ).
 
 open_docs(Db, Infos, Missing) ->
+    InfoMap = #{Id => FDI || #full_doc_info{id = Id} = FDI <- Infos},
     lists:flatmap(
         fun({Id, Revs, _}) ->
-            FDI = lists:keyfind(Id, #full_doc_info.id, Infos),
-            #full_doc_info{rev_tree = RevTree} = FDI,
+            #full_doc_info{rev_tree = RevTree} = map_get(Id, InfoMap),
             {FoundRevs, _} = couch_key_tree:get_key_leafs(RevTree, Revs),
             lists:map(
                 fun({#leaf{deleted = IsDel, ptr = SummaryPtr}, FoundRevPath}) 
->

Reply via email to