From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id MjFHNRNNjmD0XQAAgWs5BA (envelope-from ) for ; Sun, 02 May 2021 08:56:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id uB4/MBNNjmCzFgAAbx9fmQ (envelope-from ) for ; Sun, 02 May 2021 06:56:19 +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 5FDCE1FCEC for ; Sun, 2 May 2021 08:56:19 +0200 (CEST) Received: from localhost ([::1]:45920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ld61a-0002Ok-9P for larch@yhetil.org; Sun, 02 May 2021 02:56:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ld60h-0002EH-RL for emacs-orgmode@gnu.org; Sun, 02 May 2021 02:55:23 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:36600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ld60g-0001s8-4M for emacs-orgmode@gnu.org; Sun, 02 May 2021 02:55:23 -0400 Received: by mail-lf1-x12c.google.com with SMTP id n138so3450816lfa.3 for ; Sat, 01 May 2021 23:55:21 -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=gDsaXQt9dVbI0K6JN6yQ7Z4k03W8odCJj6jCGnQhl+g=; b=QX6WZEYWJB9yltjHAizDJIS/9gydPQuAEDLyv6tAYtvqvkBMASLZsPPUl+fLEWkkYl mj1RLBXR1PNfYLowyUwP/uHsV8tk6Ik7Y6kaXEEtEQINuyPDhsVrdC3f8heahWLn7b+O 0bxR3Ih0CKvd3bRgSzI/kZraVtZpOUjs51dWOgqppIfNUIyritHzRMZH3ULYoTW1SEpi mUV7gxs5iV1pzcQRtFjTnnEmiCc7kb1sKp9UiPwMywnE2FOsPCa3OiAsuH6aPafQvxKS WdQvTbA+OQ8k5JgsE1ReSy09DysU9CPg0/qU6UCDXiRqAPBBcGeh3gdekS8k/Z0/zRt9 TcSQ== 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=gDsaXQt9dVbI0K6JN6yQ7Z4k03W8odCJj6jCGnQhl+g=; b=mP5Js1nRxdi0gXakQWvIStbsMIt5hYM80JhXw1kcZ65KDtExlbOn2MGvo+25XlazwZ Fb8ZzoMmgUELqm4NumXHljl3ayAiJwCexTG8b5KfT+xELEH9n8Razxm6IPp6rN238rvu GENRG+8dMR0GcJk/iDRf7FME0Xczlby0vbfRr1kkwXvpfXLvQIczA/5fyLRZE2VM/AoA 0gYxGj8k84ywiGOhFn/a5mmkT4t93JIMcJR7RSS47yosMCU2QyEZXfSoeskPoqSmRQaD Rfn2me2fUbXlMSYDEbTp8D6ews830HwKK33eVeaYHkhWGZoQeqvsVj9KG8fxriys6jR0 thNw== X-Gm-Message-State: AOAM530jAW7uNoJA1c4yPfaQ+vWqtj+fORor1ZeH8htZgj2U1CZsny3s KKnBQf8L4rzjDK+VTCxCgAA= X-Google-Smtp-Source: ABdhPJyjQNC1Ay242Exiq0WayQWilSTfU1/R3e2Fz1gFl+WWohIBxPpnPOW4ha2Fx9T/eY1uZ6mg9w== X-Received: by 2002:a05:6512:12c7:: with SMTP id p7mr8030831lfg.494.1619938519465; Sat, 01 May 2021 23:55:19 -0700 (PDT) Received: from localhost ([91.210.107.197]) by smtp.gmail.com with ESMTPSA id m11sm819498ljp.36.2021.05.01.23.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 23:55:19 -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> <877dklxecq.fsf@localhost> Date: Sun, 02 May 2021 14:59:44 +0800 Message-ID: <875z01d3j3.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=yantar92@gmail.com; helo=mail-lf1-x12c.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=1619938579; 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=gDsaXQt9dVbI0K6JN6yQ7Z4k03W8odCJj6jCGnQhl+g=; b=f1QJEAOVcpV93Y0DuZyRKmPYsnJU5GwevAUKT+h5k6Hg3YVM6Xb0xTlClchmg9TWo+MpDi +m3KEKooVBwnLmjP3ZWHmvuxcUtM7HTb7dY2I26yjere9zXyMWe/ERO4/5nzErEmHXRJxT BRfHD+Ec3nUx/Ikf0PSQNSwzR72WfB4kUrAVicGzxtLRLo5AgoUXfRl+zvs68dd8HDj9O4 ruhmHG+TI2jtY69jZwI8yy6d3IrG07W10PtRJ81gqZ+Ez3KluKmDv6Zv0WQUTy4b2fiM/r pqWtn3k8w1/CKAhw/zTWEqr8sQnAur5ffHYBkNPNpnKs1GPdpHSti67RTIt8lg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619938579; a=rsa-sha256; cv=none; b=EoSDUrNmHSmj0tNO9Bv/ajLklw9+Ijrqg12zs/Ee4iyK9dexuUo/hsMh1IV1qTnOZ55/7R xnb4akU749dn0X9YpJaNxeNY2ysJyTW0WnIKhgfLeRkH+qngBZLTKrFcGFgsxTDRinmE+G PtU5iB9ZR0taUD+2dAiMfINztfgK9t6E5XJVAsa2lGiqFgUqsq8Z4iDV5esldToq/cLCs3 YiELV/6zZDHl1X+UUn+uw57Ezpg+3NOEvCnr792wACTHs07sKkiUP392Du7eIg8ooybsZw UvvbWGfX508+7Rif2+jUTITxRzzLTPj3l/WAuzvYn6Ezf0cf65MO/+j8byaerQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=QX6WZEYW; 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=QX6WZEYW; 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: 5FDCE1FCEC X-Spam-Score: -2.66 X-Migadu-Scanner: scn0.migadu.com X-TUID: 55O0ou0o2PHu Maxim Nikulin writes: > Some additions. org-outline-path-cache is used solely by > org-refile-get-targets (maybe there are some calls in other packages) > but it efficiency is questionable. It was not clear for me earlier that > the cache is reset before each scan through a buffer. So if > org-refile-use is disabled, org-outline-path-cache from previous run of > org-refile or org-goto is not used as well. A query to > org-outline-path-cache requires at least one backward search and hash > lookup. During sequential scan in org-refile-get-targets it is enough to > have previous heading path to update it when new heading is found. I > think, org-outline-path-cache should be deprecated. At least helm-org-ql and helm-org are using `org-get-outline-path' with cache. I do think it is useful. Though, indeed, not as fast as single-pass scan. Probably, we can rewrite the code of `org-get-outline-path' instead of deprecating it? >> Just cleanup heading text: > > I have realized what is wrong with this benchmark. It runs so fast > because it matches no headings, so it never spent time for cleaning them up. Oh. You are right. I tested with fixed benchmark and it is indeed much slower. > On 29/04/2021 21:12, Ihor Radchenko wrote: >> For the cleaned heading text, I do not think that re-calculating the >> heading text on each change is a good idea. It may degrade typing >> latency. Yet, an acceptable approach could be simply invalidating cache >> for the changed headings. Then, outline paths can be re-calculated on >> changed headings when needed. > > I agree that it is enough to invalidate cleaned heading on edit to > refresh it in org-refile-get-targets. On the other hand, I still prefer > text properties since they could be fetched even if some lines have been > added or removed before. Position-based cache is useless in such cases. Note that `org-refresh-category-properties' is using pretty much same idea. However, there is no automatic invalidation and one needs to run org-refresh-category-properties to ensure that cache is up to date. Alternatively, markers can be used here. They will not be invalidated by changes in buffer. > Concerning typing latency, it should be postponed and resumed when no > new edits is performed for certain period of time (~1s). However I am > unsure if it is possible to accurately track all affected lines since > later changes can add/remove lines before the line scheduled for > invalidation. As one option, we can accumulate the changed regions in some variable and process them on timer. As I remember, org-element-cache is already doing something similar. In fact, org-element-cache might be modified to handle outline-path as well. The problem is that org-element-cache has some difficult bugs. I tried using it multiple times and ran into issues I was not able to debug. I may work on this in future. Best, Ihor