From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +EKiDg/aimBnfwAAgWs5BA (envelope-from ) for ; Thu, 29 Apr 2021 18:08:47 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id MKU5Cg/aimBZFAAA1q6Kng (envelope-from ) for ; Thu, 29 Apr 2021 16:08:47 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BBA492529E for ; Thu, 29 Apr 2021 18:08:46 +0200 (CEST) Received: from localhost ([::1]:38326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lc9DZ-0005Fw-Vx for larch@yhetil.org; Thu, 29 Apr 2021 12:08:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lc99g-0003AO-3l for emacs-orgmode@gnu.org; Thu, 29 Apr 2021 12:04:44 -0400 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:38708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lc99a-0004NH-2N for emacs-orgmode@gnu.org; Thu, 29 Apr 2021 12:04:43 -0400 Received: by mail-ej1-x630.google.com with SMTP id r12so100667870ejr.5 for ; Thu, 29 Apr 2021 09:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:cc:date:message-id :mime-version; bh=PR+d/D6RyUISaPQbwqPhW/ZVS1yC3SPDeHyM8yeH/kA=; b=bRJsGFXHxuEIAfOuPvEdsiMDk5KbhldP2zgBARu1T/HJ2fnRiWZV+LBlGm/VHWdYn/ 3eY4JWejcObNN+3/b+P5iy1e5yJX/zeoBcVaUCaeZlG1d0rlgWyJ7iTchSx9knptl8Tr 8W2s3/F2/pV0clE0XlOfn3jEvjDd1ThSY9Wjg03RLeHCzmiYzECUludsb4p3YpnqRgVf zobAeW08/i1J3iVcTZCr4CS+d/fH1jwg0RBA+fDnIGsSoc5ztUZlcJ2qgKcyCtn159Op sYDL4tPwf4WlpIId9VicLNdpAEvJRnujq1nDztYOl8QrxYMA85GSuYXmRs8jul1erYIs zqrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:cc:date :message-id:mime-version; bh=PR+d/D6RyUISaPQbwqPhW/ZVS1yC3SPDeHyM8yeH/kA=; b=admEMI63eo8BZvd9lLGiNa+mF2hinVlJgRZDhUiT0OJdD3PSZaX08AprnW684gBB+s UhKz96ThJpGVhNhTaKmQ2vS1xHmKDI5c1X5NS2igCTwOfK6V+5JtZRbd5OKG35vX+SA+ bQdvLxVvgDSPrBnvLfsiMDbSSHTYpS33LRjXxW7PVzr6s4jfg+zk35+BBtSZcY8IznOs zTvwIEniTNgxn8tJKCTM1qndRzBtC0PmUASR9xx//0XrQV30dgLfQhUR7xpK1fs0nMhz Sw5oXQjCJkOc88UEIxuGVOOjokqDT3xrrsQt0lRzvn1B8PQDdz4BCSR2aNd68SYTQYYG GwqQ== X-Gm-Message-State: AOAM530BONkrn7lbBDjqKgwdtnAR71KnSQA9Ar4GSO9AgSg08ogkwPh8 QNiBnaqNwY6lsSth5D1uqD0= X-Google-Smtp-Source: ABdhPJxPKHwZ+LFZ+cFVIIPrJuyMlpoDuC7Spi3S/1c2u1d0qiiecdqfTO+c3Yewn+nrMV1PjpYP5A== X-Received: by 2002:a17:907:1b1e:: with SMTP id mp30mr580093ejc.532.1619712270533; Thu, 29 Apr 2021 09:04:30 -0700 (PDT) Received: from localhost ([158.255.2.9]) by smtp.gmail.com with ESMTPSA id da25sm2732572edb.38.2021.04.29.09.04.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Apr 2021 09:04:30 -0700 (PDT) From: Ihor Radchenko To: Maxim Nikulin Subject: Re: [PATCH] Bug: fragile org refile cache In-Reply-To: References: <87v98598un.fsf@localhost> <87k0olxjpz.fsf@localhost> Date: Fri, 30 Apr 2021 00:08:53 +0800 Message-ID: <877dklxecq.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=yantar92@gmail.com; helo=mail-ej1-x630.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619712526; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=PR+d/D6RyUISaPQbwqPhW/ZVS1yC3SPDeHyM8yeH/kA=; b=D9B3RaIwKgyRaG/iOtmGLnr5D7lbRFNenIDRtF0r8BFFMk5/acA9UEf1PacB6v9X42ekfD /Xr92Iolb8UWNIHRJA8TGLNuL/JkF+lcm38AelQK4WKaudnWsvUsubf673R6HsPxR7ZQos YFc3+i1Q/jk3Bzs2WuIIKenaKwA34MtjieKdrbnz2Y0raAfXVgWu5Nut3uL8cnVXbLgi5t OFTHKfcaeD3epQfj+SzwHE0Wr3mYlDt7Qo+HWednbcedt94q+fYguWCP1if/M01OdCIK4U bj7JrKHNsUFWi3OZNPYHvwArS+CvSWF/4V52ypop2h4u+j94Uv0RfcuDcbWA6Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619712526; a=rsa-sha256; cv=none; b=OHYQo1iR9lxc00bO2smGOzdATg/KMraJ94sx0h6hd77cwswjy8MQmOfy2+UDjr30BuGAxt rGvbvNsxEw3mp85gC2zWXa0ZnsuLdRYgqDRzTHQ7LQCHZ/BaECYf8QMblKmxAMC5MjrR/f jcNJYBIdo7kKrpg+2RNQwZwaGteVAuZawgExEcQHfbhpQwFIM2Kh5qFFCq8xWGgmtfQXHk qSWvFBy98M/jg7UfBohsvQxtG1NJYOYA2vmmaqnZEgCkyHjTYS9ofejp5AEvXSLvMs9mlZ Ni5K/1N3I3dGcNotmKqIFKCbjTFxoOMkvtJyHLSIhhMe23QY/0rm7qZwD2Y5tA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=bRJsGFXH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.66 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=bRJsGFXH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: BBA492529E X-Spam-Score: -2.66 X-Migadu-Scanner: scn0.migadu.com X-TUID: ArL7k+BOdB8+ Maxim Nikulin writes: > Curiously my experience is that avoiding this lazy cache with > backtracking and maintaining custom structure during sequential scan of > the buffer works several times faster. My experience is exactly opposite. Or maybe I miss something. Can you elaborate? > ... However it is appropriate time to > populate the cache you mentioned. Unfortunately it is still necessary to > cleanup heading text, and it consumes significant time. Did you do any benchmarks? I just tried Outline path without cache: (benchmark-run 1 (goto-char (point-min)) (while (re-search-forward "^\\*+" nil t) (org-get-outline-path t nil))) => (6.051079914 1 0.2864724879999869) Outline path with cache: (benchmark-run 1 (goto-char (point-min)) (while (re-search-forward "^\\*+" nil t) (org-get-outline-path t nil))) => (1.658461165 0 0.0) Just cleanup heading text: (benchmark-run 1 (goto-char (point-min)) (while (re-search-forward "^\\*+" nil t) (let ((case-fold-search nil)) (looking-at org-complex-heading-regexp) (if (not (match-end 4)) "" ;; Remove statistics cookies. (org-trim (org-link-display-format (replace-regexp-in-string "\\[[0-9]+%\\]\\|\\[[0-9]+/[0-9]+\\]" "" (match-string-no-properties 4)))))))) => (0.013364877 0 0.0) Best, Ihor