From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id MBr5GyKpNWJCQgAAgWs5BA (envelope-from ) for ; Sat, 19 Mar 2022 10:57:54 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id cECQFCKpNWLQXAAAG6o9tA (envelope-from ) for ; Sat, 19 Mar 2022 10:57:54 +0100 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 04D1E3C99C for ; Sat, 19 Mar 2022 10:57:53 +0100 (CET) Received: from localhost ([::1]:50512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVVqK-0006al-8q for larch@yhetil.org; Sat, 19 Mar 2022 05:57:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVVpK-0006aP-2K for emacs-orgmode@gnu.org; Sat, 19 Mar 2022 05:56:50 -0400 Received: from [2607:f8b0:4864:20::62e] (port=45938 helo=mail-pl1-x62e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVVpI-0002rv-D6 for emacs-orgmode@gnu.org; Sat, 19 Mar 2022 05:56:49 -0400 Received: by mail-pl1-x62e.google.com with SMTP id k6so1785242plg.12 for ; Sat, 19 Mar 2022 02:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=oKhqvHOgXn0LQMQXsYad9c/SlNHF6SBg3+S/lFq6v6s=; b=OQfodBkt1kpBhx4uxVvPMhGvr2adslnMjQUXxcjos4kV9NE6JBUDqeptcXrJSNFoWw Xck39rpJNCkytYbxWsMVnhBHIhJCCViXinjbYB8RKvrF5riRmevXRyLrzZ8Q1wJNCzj5 KZ57o9RSzTyXdmqipTVv3QbkdGsSiqSQBn0QE9ofqgVWQNSKLjm7Gmvy2VAmKh6r+18N mJvZUd9SklpEFH0vRT/tmx0KLqYP35GAYsbsPa0b8f+xW2yVDAXqvViYptJ0zr3sY3lx HEspfz5PVrAF9CJSsMT+QVFu7eSrOWj+JBlFzris0IBxg/YNo/PeXNVqyizf0Or1TnWj cgvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=oKhqvHOgXn0LQMQXsYad9c/SlNHF6SBg3+S/lFq6v6s=; b=IluhJRfhnJbT37/9XMEJK4ELk1ck1vxMQdrrGT2CPMltLQdrCSmdnrby+k7Pt12IUW LXcVOT4VRIp8WVktyajoJ7GP2l93wiB+sHXx1kNvk5q5vgnl6LLMW5wOPzTgFUXaeWTB gr/j4qxmsc9g60CfxJUc/oEw0YakccPs+/wZ9tN65CGGM3CEmBl6T087LmZbjvpGlX9d 7Z+bUM+Rn4yd3mSAXBrfzbbJfgiEa5JX/TyoF1kOZwwObBTpwzTFoAst5WX/sR7H4Bdm WHipxzHxMFk3Q0i36xJ42/yeyQ16mgJILKhXrUB6vSSU4GKKuZZMfZO/3VqBMyGjP4J7 kLZA== X-Gm-Message-State: AOAM531slbfsuNfTlao4vTXiv213bKVS+6hcQVWvizKFYbslhrDPVfp1 MTCDrUBjCrPqkxwW3JOF1aA= X-Google-Smtp-Source: ABdhPJz8vxOzN95Ebad8H5e21eS2V9cZv+PCsmGGtP+egresVtwGhzozKLPkkM9TiFqsCydDw/AcCg== X-Received: by 2002:a17:90a:a60c:b0:1bd:6058:1dd9 with SMTP id c12-20020a17090aa60c00b001bd60581dd9mr26034150pjq.118.1647683806953; Sat, 19 Mar 2022 02:56:46 -0700 (PDT) Received: from localhost ([45.128.72.3]) by smtp.gmail.com with ESMTPSA id u10-20020a056a00124a00b004f783abfa0esm12498885pfi.28.2022.03.19.02.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Mar 2022 02:56:46 -0700 (PDT) From: Ihor Radchenko To: Jamie Matthews Subject: Re: [BUG] org-cite: 10 second hang opening a ~4k org file with 10MB bibtex library [9.5.2 (9.5.2-g91681f @ /home/jdm204/.config/emacs/straight/build/org/)] In-Reply-To: References: <87pmmifirh.fsf@localhost> <87fsnefg8b.fsf@localhost> Date: Sat, 19 Mar 2022 17:57:15 +0800 Message-ID: <87cziifeo4.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62e (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=yantar92@gmail.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: "emacs-orgmode@gnu.org" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1647683874; 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=oKhqvHOgXn0LQMQXsYad9c/SlNHF6SBg3+S/lFq6v6s=; b=mX+yo9nBTlpVj72jLxP1vN8Tas08WvynnHq7SQK3u6sexWwM2sPE7Wi4iN8oRYpAxtq+66 ld9ZuEgZFhxb9COJjSanifoTpYyzLYvucEF2fS0D4XlxLt/Q9ltgm4rAHfsDswRWbPeJl8 i2IPsqU5Kef0sgEXBnwuu8IW1k75Yp0FDOrh69c+X807XnCg36Zy+5jniM1cTCNwVpb0Yx hm91BIasGOcepDgyJoFnG5n0Q3IHJaDCqcqvJU2P+FwE3feZbh36VqrHOTSFGFoGSMOZ+V QwuDS2T9cH2I240QL0FqeCc4g0iRYSDN6OMpOzFkH9FOLxdxk9SNrBZetJYXdg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1647683874; a=rsa-sha256; cv=none; b=bFYehcVXnRZMVlzfUY7yxL6iTmsAWWCcoXVSBe6oij4XYYIPpcjcT6jcHS/VhMFNweYs2d EILVgBc/9Z17QduBShAN2H3Oy3mUlfVxnJY3qO3rhipR+c5sQk94Nu8r1vVBxlmx1Cufvn p3oIjLCc6GbfOaPYfX6AKkWryo3G4Y2oLrQNTGFWT3JnoRE8dapq6M3c2o1BZLjOnNIP5j dLpqZhgwUr4+/Yx6M9Xbg/tScCd/vqZPeA5FqDXGRCxJkuqz785Jw5dpb3/25jTJY5l7h0 0wt4wi0+tWW6Ai4C2YZPhTbNMereBLU+En2Awvm5257nvAVIXs89qZosq02F7Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OQfodBkt; 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" X-Migadu-Spam-Score: -3.64 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OQfodBkt; 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" X-Migadu-Queue-Id: 04D1E3C99C X-Spam-Score: -3.64 X-Migadu-Scanner: scn0.migadu.com X-TUID: gAOEbjawBKJN Jamie Matthews writes: > Thanks: > > ``` > org-cite-basic-activate 59 10.724349447 0.1817686346 > org-cite-basic--parse-bibliography 129 10.559936049 0.0818599693 > org-cite-basic--all-keys 59 7.830202561 0.1327152976 > org-cite-basic--get-entry 70 2.7772344940 0.0396747784 > ``` org-cite-basic--parse-bibliography appears to be the main bottleneck. I tried to write a quick fix (untested). Can you try to redefine org-cite-basic--parse-bibliography to the version below (note an extra defvar) and let me know how it goes: (defvar org-cite-basic--file-id-cache nil "Hash table linking files to their hash.") (defun org-cite-basic--parse-bibliography (&optional info) "List all entries available in the buffer. Each association follows the pattern (FILE . ENTRIES) where FILE is the absolute file name of the BibTeX file, and ENTRIES is a hash table where keys are references and values are association lists between fields, as symbols, and values as strings or nil. Optional argument INFO is the export state, as a property list." (unless (hash-table-p org-cite-basic--file-id-cache) (setq org-cite-basic--file-id-cache (make-hash-table :test #'equal))) (if (plist-member info :cite-basic/bibliography) (plist-get info :cite-basic/bibliography) (let ((results nil)) (dolist (file (org-cite-list-bibliography-files)) (when (file-readable-p file) (with-temp-buffer (when (or (file-has-changed-p file) (not (gethash file org-cite-basic--file-id-cache))) (insert-file-contents file)) (unless (gethash file org-cite-basic--file-id-cache) (puthash file (org-buffer-hash) org-cite-basic--file-id-cache)) (let* ((file-id (cons file (gethash file org-cite-basic--file-id-cache))) (entries (or (cdr (assoc file-id org-cite-basic--bibliography-cache)) (let ((table (pcase (file-name-extension file) ("json" (org-cite-basic--parse-json)) ("bib" (org-cite-basic--parse-bibtex 'biblatex)) ("bibtex" (org-cite-basic--parse-bibtex 'BibTeX)) (ext (user-error "Unknown bibliography extension: %S" ext))))) (push (cons file-id table) org-cite-basic--bibliography-cache) table)))) (push (cons file entries) results))))) (when info (plist-put info :cite-basic/bibliography results)) results))) Best, Ihor