This is an automated email from the ASF dual-hosted git repository. nickva pushed a commit to branch mem3-rep-open-docs-map in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit a40ef1cec498008ae6b6e9a4db5e249033560dd5 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}) ->
