From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id AE//OEZKYGeUowAA62LTzQ:P1 (envelope-from ) for ; Mon, 16 Dec 2024 15:41:59 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id AE//OEZKYGeUowAA62LTzQ (envelope-from ) for ; Mon, 16 Dec 2024 16:41:59 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iL8jhkCe; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1734363718; a=rsa-sha256; cv=none; b=INjynVpISWSYcMPyzCKhHbifq+akc0hiMmEwHIskUlwNdf69n6R9WnLiHKdy/4mD0tL3A1 TSEguYBcqGUChZoAz5wqMvTVhYNwYdKdUdQBh57hdhWDDe1E79BqzcPmCSP3/wP3TVS1PQ /J4nW3YSNKTEcO3PWbtawlVsd5NIGmJhODl5OiUUL1gqDEi0MFMm3SrpgNx8lAqL18fJOi QcsYIgKFKM0cQE4iAjAvD7+/ksBhyAY1a/i5eNHRUCl8tuDXUY74xUpB/PpStY3M1zvpMV f+fiQGwiDTubxE7On8NqGE2GeX5DiCZmt4F998wrh4UkV8e85ZJJQgVCBN3BFQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iL8jhkCe; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1734363718; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=hJQjL3KgsK+LZrNM285nkCO6t7vdpU/bJW+FjPQAi90=; b=Ven6IKLyUSKWPAiLvRcVP5PLLWiqOmMzgzjIp9pZIqQ9NazENeIyhViMXTwLq0iCVNRov2 HhBL7BNGZDUjiEevutA+F3UwqwsY4OfBZBkRCX5RXgp7jbbaXpxlJMg9C6mJKTiCC5AKEr RP9YV07PdxgJu3316u+FesxH1I0lhk+v7c6w7opo4ANZgogyxM21vCOOQSXICLgXrOdINQ pd/nSjhNCpSZyg+9Jf6l5EV2M5blNS8sWchmVDJ5E+CWPWz4xayhE/gajq/fJQMnnZAwia BWAQQjZ0Uh3/SkSVK/Y/IwfuKQvqdFifatPmu8xyIiAWtq4zU8Dnm3HwOiYjEQ== 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 9C5A483889 for ; Mon, 16 Dec 2024 16:41:58 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNDDq-0002OM-PF; Mon, 16 Dec 2024 10:41:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNDDp-0002O8-22 for emacs-orgmode@gnu.org; Mon, 16 Dec 2024 10:41:25 -0500 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNDDn-00036W-5n for emacs-orgmode@gnu.org; Mon, 16 Dec 2024 10:41:24 -0500 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-aa6c0dbce1fso588100766b.2 for ; Mon, 16 Dec 2024 07:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734363681; x=1734968481; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=hJQjL3KgsK+LZrNM285nkCO6t7vdpU/bJW+FjPQAi90=; b=iL8jhkCeBBELWGUmmrWbpU8/Z4rxriVMDjgmhGpXgsNndxwM00S8joX035Zddnb+yh DxDGSaoftXiVifVMQH7a8POHZ9unshyE6AY5wopDn3KFndOmLmLEqocbqR759AHJm8EP A+IeepZrZ5UIASyA4HQXVxaYOkqxj008qy/bNlX4esYxQQBnkglzmZ2HZrIcuqcCH6jC hYHmPKFu8VMFYmBpvCKQgR8HI/WeAWgMJ28hjjeXszst2wh8hGTB+fxVUuX1wiDicVd3 6Hxl3Z5K1gBk56OoUItuQdFjapgVLC8DM7R1NbU7r51hl4sJLyaV8rNgkSE/LENRoviJ m4Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734363681; x=1734968481; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=hJQjL3KgsK+LZrNM285nkCO6t7vdpU/bJW+FjPQAi90=; b=Xpojy6YVp0oZRA+v9bQVdaLRK7v78ZZ+Q2UZW9e2MAyxMms2uRZ4L7WORWSH2p3fv+ DL3c7ANz7oeMt2qCkS9io+SOSehdxefVoApxCoZtpe1GOg2iVrhB1lzmLSMHL03SGP+Q Lboepm/nzFNygm50bLJfJUu2J0L0H2ETP28UW48LB3jpZM6jAvUgl+6ADULXZQ8Dn1T4 tvKf8CjiUYsc+Tu8c9Gt1uNFoFcxmr9sqYaYMDEXIh2C1IzZ1N+YqshsAc07QT4z24xA Y5semoTQEesOe4V+TIM/JHRVZUC1D9naHScWjAVUPvQlIX/iUSO3ZrNrN02etyWQbZvm 1UOA== X-Gm-Message-State: AOJu0Yxbkh2seFe6DSXWUwmx1xEzE6Cv12zV6qHvTkTtvFa0E5O/TKl1 cNnChqpZ7o/DOdhdGeUH/6LH4Z0egMR2ssxFEpTtR2Q/YM/fOBb1uuyIrliA2IUJegjh3lnMEux FFtdiR8qzeaYxFY97qX3ZMDvtJVi5lQ== X-Gm-Gg: ASbGncvVcy+r1tHZxNNbrbmlSva1/CBkplaKpLYi7aokPy42WDyg3ashfYL5UXyPRkD fFsiwwDHdfR7wsKPxqxNf6A9OeuXnFdJ2lRFL6QDF2VYQTE8+1JC0zuTTWXBZQfRRzT1A1ak= X-Google-Smtp-Source: AGHT+IEoebXApSRJGl4G4o7DdQEqUgYLgAv+3JRwbD1OVZEyEc9tIkJKVZu9Er/F1FP0xiNz6estRMHBKcKmJSSUuXE= X-Received: by 2002:a05:6402:50d0:b0:5d0:9054:b119 with SMTP id 4fb4d7f45d1cf-5d63c3dc1d3mr25428787a12.21.1734363680950; Mon, 16 Dec 2024 07:41:20 -0800 (PST) MIME-Version: 1.0 From: Michael Brand Date: Mon, 16 Dec 2024 16:41:09 +0100 Message-ID: Subject: Performance of property drawers in Org cache To: Org Mode Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=michael.ch.brand@gmail.com; helo=mail-ej1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -9.44 X-Spam-Score: -9.44 X-Migadu-Queue-Id: 9C5A483889 X-Migadu-Scanner: mx12.migadu.com X-TUID: wrJd1GXl52ro Hi all Hello again, it's been a long time since I last followed this list regularly or posted regularly (until 2019, code contributions until 2016). Now I would like to report issues with the performance of property drawers in Org cache. The time it takes to open an Org file with a useful amount of property drawers like in test_1.org has increased too much for me to update from Org mode 9.5, see the table below. Org loading performance has also degraded a bit but I assume and hope that the amount is not more than necessary for the convenience of having more Org features preloaded. To do some homework I looked in Org news, the mailing list, the Commentary of org-element-ast.el and an overview of org-element-ast.el. The beginning of the result of ~(org-element-cache-map #'car :granularity 'element)~ (as found in test-org-element.el) and its length of 3003 for test_1.org look completely reasonable to me. ~org-element--cache-map-statistic t~ does not reveal where the by far large rest of the total time goes: "Total time: 10.668449 sec. Pre-process time: 0.000000 sec. Predicate time: 0.014772 sec. Re-search time: 0.000000 sec.". I am surprised that a repeated use of ~org-element-cache-map~ is still quite slow: 2.0 s without statistic for iterating over 3003 cached AST nodes to collect their ~car~?. Obviously I am a bit overchallenged with the Org cache and hope that someone can look into this. Out of curiosity: What consumes time during killing an Org buffer that seems to scale with the buffer/cache size? What has to be done more than just garbage collection that can be deferred to after killing has finished? Michael * Test procedure ---------------- Benchmarking started do get complicated because of the different time sinks, so I automated the following steps 3) to 5) with ~benchmark-elapse~ etc. See the source block with the Emacs Lisp code below. 1) Change Org version and ~$ make cleanall uncompiled~ 2) ~$ emacs -Q --eval '(add-to-list (quote load-path) "~/path/to/org-mode/lisp")'~ 3) First just load Org by opening an empty Org file and kill the buffer (table column "Load Org") 4) Then open test_1.org and kill the buffer (table column "test_1.org") 5) Then open test_2.org and kill the buffer (table column "test_2.org") The times in seconds [s] are for opening the file and in parenthesis for killing the buffer, rows in reverse chronological order: | Org version | Load Org | test_1.org | test_2.org | | | [s] | size: 1000 | size: 400 | | | | [s] | [s] | | | | | | |-------------+-----------+------------+------------| | eebc9be7ca | 3.3 (0.0) | 13.3 (5.4) | 1.7 (0.7) | | ... | | | | | 924a64da39 | 3.1 (0.0) | 10.7 (0.2) | 1.3 (0.1) | | 924a64da39^ | 2.6 (0.0) | 5.4 (0.2) | 0.7 (0.1) | | ... | | | | | release_9.6 | 2.9 (0.0) | 6.9 (0.0) | 1.8 (0.0) | | ... | | | | | release_9.5 | 2.3 (0.0) | 0.2 (0.0) | 12.1 (0.0) | Commit eebc9be7ca: The main branch as of [2024-12-16 Mon]. Commit 924a64da39: - Author: Ihor Radchenko - Date: Sat May 20 13:29:04 2023 +0200 - Title: org-element: Use the new org-element-ast library All with Emacs 29.4 on macOS. * Minimal working examples -------------------------- test_1.org depends on ~overview~ and drawers that may be property drawers or just drawers and may be empty. Shell command for size 1000: : $ (echo '#+startup: overview' && for ((i = 1; i <= 1000; i++)); do printf '* %d\n:PROPERTIES:\n:END:\n' $i; done ; ) > test_1.org test_2.org depends on ~overview~, the drawers may be empty. Shell command for different size 400: : $ (echo '#+startup: overview' && for ((i = 1; i <= 400; i++)); do printf ':MY_DRAWER_%d:\n:END:\n' $i; done ; ) > test_2.org * Test automation ----------------- #+begin_src emacs-lisp :eval no (let ((test-0-open-file -1.0) (test-0-kill-buffer -1.0) (test-1-open-file -1.0) (test-1-kill-buffer -1.0) (test-2-open-file -1.0) (test-2-kill-buffer -1.0)) (require 'benchmark) ;; ,test_0.org (when t (setq test-0-open-file (benchmark-elapse (find-file "~/z/,test_0.org"))) (switch-to-buffer "*Messages*") (message (concat "INF: test-0-open-file = " (number-to-string test-0-open-file)))) (when t (setq test-0-kill-buffer (benchmark-elapse (kill-buffer ",test_0.org"))) (switch-to-buffer "*Messages*") (message (concat "INF: test-0-kill-buffer = " (number-to-string test-0-kill-buffer)))) ;; ,test_1.org (when t (setq test-1-open-file (benchmark-elapse (find-file "~/z/,test_1.org"))) (switch-to-buffer "*Messages*") (message (concat "INF: test-1-open-file = " (number-to-string test-1-open-file)))) (when t (setq test-1-kill-buffer (benchmark-elapse (kill-buffer ",test_1.org"))) (switch-to-buffer "*Messages*") (message (concat "INF: test-1-kill-buffer = " (number-to-string test-1-kill-buffer)))) ;; ,test_2.org (when t (setq test-2-open-file (benchmark-elapse (find-file "~/z/,test_2.org"))) (switch-to-buffer "*Messages*") (message (concat "INF: test-2-open-file = " (number-to-string test-2-open-file)))) (when t (setq test-2-kill-buffer (benchmark-elapse (kill-buffer ",test_2.org"))) (switch-to-buffer "*Messages*") (message (concat "INF: test-2-kill-buffer = " (number-to-string test-2-kill-buffer)))) (kill-new (concat " " (format "%.1f" test-0-open-file) " (" (format "%.1f" test-0-kill-buffer) ") |" " " (format "%.1f" test-1-open-file) " (" (format "%.1f" test-1-kill-buffer) ") |" " " (format "%.1f" test-2-open-file) " (" (format "%.1f" test-2-kill-buffer) ") |"))) #+end_src