Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7352A200C6F for ; Tue, 9 May 2017 22:20:53 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 71E12160BB6; Tue, 9 May 2017 20:20:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B892C160B9A for ; Tue, 9 May 2017 22:20:52 +0200 (CEST) Received: (qmail 25673 invoked by uid 500); 9 May 2017 20:20:51 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 25664 invoked by uid 99); 9 May 2017 20:20:51 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 May 2017 20:20:51 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 4E010811A0; Tue, 9 May 2017 20:20:50 +0000 (UTC) Date: Tue, 09 May 2017 20:20:50 +0000 To: "commits@couchdb.apache.org" Subject: [couchdb] branch COUCHDB-3298-optimize-writing-btree-nodes updated: Fix check for prefix of suffix MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <149436125003.20559.12133950386392940592@gitbox.apache.org> From: davisp@apache.org Reply-To: "commits@couchdb.apache.org" X-Git-Host: gitbox.apache.org X-Git-Repo: couchdb X-Git-Refname: refs/heads/COUCHDB-3298-optimize-writing-btree-nodes X-Git-Reftype: branch X-Git-Oldrev: fd244ec71814be4524c76f2efbe91b54ccacfc4d X-Git-Newrev: fd0e0e33d40f666dcba07440cc2858e7f7b459f8 X-Git-Rev: fd0e0e33d40f666dcba07440cc2858e7f7b459f8 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.3.dev Auto-Submitted: auto-generated archived-at: Tue, 09 May 2017 20:20:53 -0000 This is an automated email from the ASF dual-hosted git repository. davisp pushed a commit to branch COUCHDB-3298-optimize-writing-btree-nodes in repository https://gitbox.apache.org/repos/asf/couchdb.git The following commit(s) were added to refs/heads/COUCHDB-3298-optimize-writing-btree-nodes by this push: new fd0e0e3 Fix check for prefix of suffix fd0e0e3 is described below commit fd0e0e33d40f666dcba07440cc2858e7f7b459f8 Author: Paul J. Davis AuthorDate: Tue May 9 15:20:24 2017 -0500 Fix check for prefix of suffix --- src/couch/src/couch_btree.erl | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/couch/src/couch_btree.erl b/src/couch/src/couch_btree.erl index df01788..0882993 100644 --- a/src/couch/src/couch_btree.erl +++ b/src/couch/src/couch_btree.erl @@ -487,33 +487,38 @@ write_node(Bt, OldNode, NodeType, OldList, NewList) -> end. can_reuse_old_node(OldList, NewList) -> - Prefix = remove_prefix_kvs(hd(OldList), NewList), - case contains_old_list(OldList, NewList, 0) of + {Prefix, RestNewList} = remove_prefix_kvs(hd(OldList), NewList), + case old_list_is_prefix(OldList, RestNewList, 0) of {true, Size, Suffix} -> ReuseThreshold = get_chunk_size() * ?FILL_RATIO, - if Size < ReuseThreshold -> false; true -> + if Size < ReuseThreshold -> blog("XKCD: NOT FULL ENOUGH", []), false; true -> + blog("XKCD: OPTIMIZED ~p ~p", [length(Prefix), length(Suffix)]), {true, Prefix, Suffix} end; false -> + Ks1 = [element(1, KV) || KV <- OldList], + Ks2 = [element(1, KV) || KV <- NewList], + blog("XKCD: OldList not contained! ~p vs ~p", [Ks1, Ks2]), false end. remove_prefix_kvs(KV1, [KV2 | Rest]) when KV2 < KV1 -> - [KV2 | remove_prefix_kvs(KV1, Rest)]; -remove_prefix_kvs(_, _) -> - []. + {Prefix, RestNewList} = remove_prefix_kvs(KV1, Rest), + {[KV2 | Prefix], RestNewList}; +remove_prefix_kvs(_, RestNewList) -> + {[], RestNewList}. -% No more KV's in the old node so its contained -contains_old_list([], Suffix, Size) -> +% No more KV's in the old node so its a prefix +old_list_is_prefix([], Suffix, Size) -> {true, Size, Suffix}; % Some KV's have been removed from the old node -contains_old_list(_OldList, [], _Size) -> +old_list_is_prefix(_OldList, [], _Size) -> false; % KV is equal in both old and new node so continue -contains_old_list([KV | Rest1], [KV | Rest2], Acc) -> - contains_old_list(Rest1, Rest2, ?term_size(KV) + Acc); -% KV mismatch between old and new node so not contained -contains_old_list(_OldList, _NewList, _Acc) -> +old_list_is_prefix([KV | Rest1], [KV | Rest2], Acc) -> + old_list_is_prefix(Rest1, Rest2, ?term_size(KV) + Acc); +% KV mismatch between old and new node so not a prefxi +old_list_is_prefix(_OldList, _NewList, _Acc) -> false. modify_kpnode(Bt, {}, _LowerBound, Actions, [], QueryOutput) -> -- To stop receiving notification emails like this one, please contact ['"commits@couchdb.apache.org" '].