From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GA+wMsszJ2AKLwAA0tVLHw (envelope-from ) for ; Sat, 13 Feb 2021 02:04:59 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id WBBQLsszJ2CkLwAAbx9fmQ (envelope-from ) for ; Sat, 13 Feb 2021 02:04:59 +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 CCC9419869 for ; Sat, 13 Feb 2021 03:04:58 +0100 (CET) Received: from localhost ([::1]:53976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAkIq-0003uI-Bi for larch@yhetil.org; Fri, 12 Feb 2021 21:04:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAkGi-0003u7-GK for emacs-orgmode@gnu.org; Fri, 12 Feb 2021 21:02:45 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:36231) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAkGZ-0004Up-V2 for emacs-orgmode@gnu.org; Fri, 12 Feb 2021 21:02:44 -0500 Received: by mail-wm1-x335.google.com with SMTP id i9so1546394wmq.1 for ; Fri, 12 Feb 2021 18:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:thread-topic:thread-index:date:message-id:reply-to :accept-language:content-language:mime-version; bh=90H1D+sq5ALjyyI88hGvWn7g+Tlvfx2t57a1foa6yi0=; b=QZarr1tIrKaGM83DO5Oz9FbsYZ1MvK6AQRgakMwV/fduxKq8v4aUKg7aTLLl/ZS115 0GtrrncHcm26f/fKmybzULhdfVcGIRS0n8ArwcTk6UmKy9hbuYcP1eUp/UCIEQzS3CKX SceidyOvYkh6rksDSW6pfiZO3v64cO2PS1QWteo4w6Z3Z9+stHDsVMKdPw8xo7bYOVKZ 6Dw8Vc7mEUZ9RVH2h5hm9AQX44oo5xpUNmZzRSuz5IQkZ8Rr3hNPNJNLeo1b9IvWwDGV 23p8WkaKQL0MwJoKNCWxKm0FwB4jXBUhNJMto8z7QVizTU4QY/uEWkAIHP7ItiRhZwc0 UDiw== 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:thread-topic:thread-index:date :message-id:reply-to:accept-language:content-language:mime-version; bh=90H1D+sq5ALjyyI88hGvWn7g+Tlvfx2t57a1foa6yi0=; b=BSK9zbsiC8o+TbeAOAIllSTm+mxM00wD2JFRtR5bOUA1EXgE1sw+/Gqkb/YmRghrz1 GzI86gCEn+HoZOWqir0CQ/fgTZl7KZOnMencm8cC7niZlKG1n+NhXvmfWSF1TwIVx/4c KkEuK3oabOuymP53GuPlh46akmfqoswtbB6bW+4C40+Fj93AX1r5m8A6vgLp3wPE+Wk4 lkmUR7Lb8R8AilK/J3bdPgvCyJLOsRePk04gl6as8ujvtElSmbbqaZmJGWmg5UN20p4f Gw0pIYAMcVXOpxpKbBSvsE6xM3xgih1+agVFQJt0d0GkrWpnPRei0fmtHta5d1AglyPB Dmuw== X-Gm-Message-State: AOAM533shuqRoF7pqmEsG7K6LYuywwx20VzZ+WDVpFcxCoDq3t7oumSq ZzuIbnxSvXQ/47yyR2RDFbexOi1NcQ== X-Google-Smtp-Source: ABdhPJzdoON+KAlgo8hAjHmJ+AKaUUIGyyExRsVxQeMTvU7dWKpYeOKoPR5plfdklNlrgYNlwxZB7g== X-Received: by 2002:a05:600c:354f:: with SMTP id i15mr1321810wmq.28.1613179694459; Fri, 12 Feb 2021 17:28:14 -0800 (PST) Received: from DB9PR08MB6633.eurprd08.prod.outlook.com ([2603:1026:c02:4051::5]) by smtp.gmail.com with ESMTPSA id t16sm6042011wrp.87.2021.02.12.17.28.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Feb 2021 17:28:13 -0800 (PST) Received: from dark (183.246.145.70) by HK0PR01CA0055.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25 via Frontend Transport; Sat, 13 Feb 2021 01:10:26 +0000 From: Christopher Miles To: Org Mode Subject: Is it possible to optimize Org Mode org-activate-links ? Thread-Topic: Is it possible to optimize Org Mode org-activate-links ? Thread-Index: AQHXAaUDeoQlAxgaaUimNLu9WXNfWw== X-MS-Exchange-MessageSentRepresentingType: 1 Date: Sat, 13 Feb 2021 01:10:28 +0000 Message-ID: Accept-Language: zh-TW, en-US Content-Language: en-US X-MS-Exchange-Organization-AuthAs: Internal X-MS-Exchange-Organization-AuthMechanism: 06 X-MS-Exchange-Organization-AuthSource: DB9PR08MB6633.eurprd08.prod.outlook.com X-MS-Has-Attach: yes X-MS-Exchange-Organization-Network-Message-Id: 3e339f89-6c1f-4220-a242-08d8cfbc261f X-MS-Exchange-Organization-SCL: -1 X-MS-TNEF-Correlator: X-MS-Exchange-Organization-RecordReviewCfmType: 0 x-clientproxiedby: HK0PR01CA0055.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::19) To DB9PR08MB6633.eurprd08.prod.outlook.com (2603:10a6:10:23d::6) Content-Type: multipart/mixed; boundary="_004_DB9PR08MB6633F71EB92F19628DD1E598A38A9DB9PR08MB6633eurp_" MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=numbchild@gmail.com; helo=mail-wm1-x335.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, HTML_MESSAGE=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: , Reply-To: Christopher Miles Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 0.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=QZarr1tI; 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: CCC9419869 X-Spam-Score: 0.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: voIvSjFErNx4 --_004_DB9PR08MB6633F71EB92F19628DD1E598A38A9DB9PR08MB6633eurp_ Content-Type: multipart/alternative; boundary="_000_DB9PR08MB6633F71EB92F19628DD1E598A38A9DB9PR08MB6633eurp_" --_000_DB9PR08MB6633F71EB92F19628DD1E598A38A9DB9PR08MB6633eurp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <#secure method=3Dpgpmime mode=3Dsign> I did an profiler (with my extension "org-link-beautify"). Here is the result of (Memory and CPU). I checked org-element-context source code, it's not so long and complex. Wh= y it caused so many items in Memory profiler result? Is it possible to opti= mize it? Here is the Emacs profiler (CPU) result: 8 2% - org-activate-links 8 2% - catch 8 2% - while 6 2% - let* 6 2% - if 6 2% - progn 6 2% - let* 5 1% - let 5 1% - if 5 1% - progn 5 1% - funcall 5 1% - org-link-beautify-display 2 0% - org-link-beautify--return-icon 2 0% org-link-beautify--warning 2 0% file-name-extension 1 0% - org-link-beautify--preview-pdf 1 0% - org-link-beautify--display-thumbnail 1 0% - create-image 1 0% - apply 1 0% - # 1 0% - image-type 1 0% - image-type-from-file-header 1 0% generate-new-buffer 1 0% - let* 1 0% - cond 1 0% - or 1 0% facep Here is the Emacs profiler (Memory) result: 1,939,896 11% - org-activate-links 1,939,896 11% - catch 1,939,896 11% - while 1,761,816 10% - let* 1,761,816 10% - if 1,697,400 9% - progn 1,658,488 9% - let* 1,511,048 8% - let 1,511,048 8% - if 1,511,048 8% - progn 1,511,048 8% - funcall 1,511,048 8% - org-link-beautify-display 947,000 5% - org-link-beautify--get-element 947,000 5% - org-element-context 947,000 5% - catch 947,000 5% - save-excursion 947,000 5% - save-restriction 947,000 5% - let* 792,384 4% - let 792,384 4% - catch 792,384 4% - while 792,384 4% - let 792,384 4% - org-element--object-lex 792,384 4% - if 792,384 4% - let* 792,384 4% - save-excursion 792,384 4% - while 661,368 3% - let 655,272 3% - setq 655,272 3% - cond 655,272 3% - let* 655,272 3% - cond 610,224 3% - let* 610,224 3% - cond 610,224 3% - if 610,224 3% - progn 610,224 3% - org-element-l= ink-parser 610,224 3% - catch 610,224 3% - let 450,480 2% - cond 225,240 1% - setq 225,240 1% - org-link= -expand-abbrev 139,248 0% - org-lin= k-unescape 131,064 0% - replac= e-regexp-in-string 8,184 0% apply 85,992 0% - if 77,808 0% not 8,184 0% - let* 8,184 0% and 163,800 0% - cond 61,440 0% or 8,184 0% setq 159,744 0% - if 98,304 0% - progn 49,152 0% if 49,152 0% - setq 49,152 0% replace= -regexp-in-string 45,048 0% - and 45,048 0% - org-element-link= -parser 45,048 0% - catch 45,048 0% - let 32,760 0% cond 12,288 0% if 131,016 0% and 154,616 0% - or 154,616 0% - org-element-at-point 154,616 0% - save-excursion 154,616 0% - save-restriction 154,616 0% - let 154,616 0% - cond 79,864 0% - progn 79,864 0% - let* 71,680 0% - org-at-heading-p 71,680 0% outline-on-heading-p 74,752 0% - org-element--parse-to 74,752 0% - catch 74,752 0% - save-excursion 74,752 0% - save-restriction 74,752 0% - let* 74,752 0% - cond 74,752 0% - if 74,752 0% - progn 74,752 0% - let* 74,752 0% outline-previous= -heading 368,568 2% - file-name-extension 36,864 0% file-name-sans-versions 133,272 0% - org-link-beautify--preview-pdf 109,788 0% - org-link-beautify--display-thumbnail 107,898 0% - create-image 107,898 0% - apply 107,898 0% - # 107,898 0% - image-type 107,898 0% - image-type-from-file-header 63,048 0% insert-file-contents-literally 32,760 0% image-type-from-buffer 126 0% generate-new-buffer 22,512 0% - org-link-unescape 22,512 0% - replace-regexp-in-string 16,368 0% apply 22,352 0% org-link-beautify--display-icon 9,216 0% - org-link-beautify--return-icon 8,184 0% org-link-beautify--warning 139,256 0% - save-excursion 139,256 0% - let 139,256 0% - unwind-protect 139,256 0% - progn 139,256 0% - org-element-link-parser 139,256 0% - catch 139,256 0% - let 103,416 0% - cond 50,168 0% - setq 50,168 0% - org-link-expand-abbrev 34,808 0% - org-link-unescape 26,624 0% replace-regexp-in-string 15,360 0% - if 15,360 0% not 30,720 0% - cond 15,360 0% or 35,840 0% - if 18,432 0% - progn 9,216 0% if 9,216 0% - setq 9,216 0% replace-regexp-in-string 8,184 0% - list 8,184 0% - let* 8,184 0% if 38,912 0% - let 38,912 0% + let* 64,416 0% + and --_000_DB9PR08MB6633F71EB92F19628DD1E598A38A9DB9PR08MB6633eurp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

<#secure method=3Dpgpmime mode=3Dsign>

I did an profiler (with my extension "org-link-beautify").

Here is the result of (Memory and CPU).

I checked org-element-context source code, it's not so long= and complex. Why it caused so many items in Memory profiler result? Is it = possible to optimize it?

Here is the Emacs profiler (CPU) result:

8   2%          - org-activate-links
8   2%           - catch
8   2%            - while
6   2%             - let*
6   2%              - if
6   2%               - progn
6   2%                - let*
5   1%                 - let
5   1%                  - if
5   1%                   - progn
5   1%                    - funcall
5   1%                     - org-link-beautify-display
2   0%                      - org-link-beautify--return-icon
2   0%                         org-link-beautify--warning
2   0%                        file-name-extension
1   0%                      - org-link-beautify--preview-pdf
1   0%                       - org-link-beautify--display-thumbnail
1   0%                        - create-image
1   0%                         - apply
1   0%                          - #<compiled 0x4c76891e673d173>=

1   0%                           - image-type
1   0%                            - image-type-from-file-header
1   0%                               generate-new-buffer
1   0%                 - let*
1   0%                  - cond
1   0%                   - or
1   0%                      facep

Here is the Emacs profiler (Memory) result:

1,939,896  11%          - org-activate-links
1,939,896  11%           - catch
1,939,896  11%            - while
1,761,816  10%             - let*
1,761,816  10%              - if
1,697,400   9%               - progn
1,658,488   9%                - let*
1,511,048   8%                 - let
1,511,048   8%                  - if
1,511,048   8%                   - progn
1,511,048   8%                    - funcall
1,511,048   8%                     - org-link-beautify-display
  947,000   5%                      - org-link-beautify--get-element<=
/code>
  947,000   5%                       - org-element-context
  947,000   5%                        - catch
  947,000   5%                         - save-excursion
  947,000   5%                          - save-restriction
  947,000   5%                           - let*
  792,384   4%                            - let
  792,384   4%                             - catch
  792,384   4%                              - while
  792,384   4%                               - let
  792,384   4%                                - org-element--object-l=
ex
  792,384   4%                                 - if
  792,384   4%                                  - let*
  792,384   4%                                   - save-excursion
  792,384   4%                                    - while
  661,368   3%                                     - let
  655,272   3%                                      - setq
  655,272   3%                                       - cond
  655,272   3%                                        - let*
  655,272   3%                                         - cond
  610,224   3%                                          - let*
  610,224   3%                                           - cond
  610,224   3%                                            - if
  610,224   3%                                             - progn
  610,224   3%                                              - org-ele=
ment-link-parser
  610,224   3%                                               - catch<=
/code>
  610,224   3%                                                - let
  450,480   2%                                                 - cond=

  225,240   1%                                                  - set=
q
  225,240   1%                                                   - or=
g-link-expand-abbrev
  139,248   0%                                                    - o=
rg-link-unescape
  131,064   0%                                                     - =
replace-regexp-in-string
    8,184   0%                                                       =
 apply
   85,992   0%                                                    - i=
f
   77,808   0%                                                       =
not
    8,184   0%                                                     - =
let*
    8,184   0%                                                       =
 and
  163,800   0%                                                  - con=
d
   61,440   0%                                                     or=

    8,184   0%                                                     se=
tq
  159,744   0%                                                 - if
   98,304   0%                                                  - pro=
gn
   49,152   0%                                                     if=

   49,152   0%                                                   - se=
tq
   49,152   0%                                                      r=
eplace-regexp-in-string
   45,048   0%                                          - and
   45,048   0%                                           - org-elemen=
t-link-parser
   45,048   0%                                            - catch
   45,048   0%                                             - let
   32,760   0%                                                cond
   12,288   0%                                                if
  131,016   0%                                       and
  154,616   0%                            - or
  154,616   0%                             - org-element-at-point
  154,616   0%                              - save-excursion
  154,616   0%                               - save-restriction
  154,616   0%                                - let
  154,616   0%                                 - cond
   79,864   0%                                  - progn
   79,864   0%                                   - let*
   71,680   0%                                    - org-at-heading-p<=
/code>
   71,680   0%                                       outline-on-headi=
ng-p
   74,752   0%                                  - org-element--parse-=
to
   74,752   0%                                   - catch
   74,752   0%                                    - save-excursion
   74,752   0%                                     - save-restriction=

   74,752   0%                                      - let*
   74,752   0%                                       - cond
   74,752   0%                                        - if
   74,752   0%                                         - progn
   74,752   0%                                          - let*
   74,752   0%                                             outline-pr=
evious-heading
  368,568   2%                      - file-name-extension
   36,864   0%                         file-name-sans-versions
  133,272   0%                      - org-link-beautify--preview-pdf<=
/code>
  109,788   0%                       - org-link-beautify--display-thu=
mbnail
  107,898   0%                        - create-image
  107,898   0%                         - apply
  107,898   0%                          - #<compiled 0x4c76891e673=
d173>
  107,898   0%                           - image-type
  107,898   0%                            - image-type-from-file-head=
er
   63,048   0%                               insert-file-contents-lit=
erally
   32,760   0%                               image-type-from-buffer
      126   0%                               generate-new-buffer
   22,512   0%                      - org-link-unescape
   22,512   0%                       - replace-regexp-in-string
   16,368   0%                          apply
   22,352   0%                        org-link-beautify--display-icon=

    9,216   0%                      - org-link-beautify--return-icon<=
/code>
    8,184   0%                         org-link-beautify--warning
  139,256   0%                 - save-excursion
  139,256   0%                  - let
  139,256   0%                   - unwind-protect
  139,256   0%                    - progn
  139,256   0%                     - org-element-link-parser
  139,256   0%                      - catch
  139,256   0%                       - let
  103,416   0%                        - cond
   50,168   0%                         - setq
   50,168   0%                          - org-link-expand-abbrev
   34,808   0%                           - org-link-unescape
   26,624   0%                              replace-regexp-in-string<=
/code>
   15,360   0%                           - if
   15,360   0%                              not
   30,720   0%                         - cond
   15,360   0%                            or
   35,840   0%                        - if
   18,432   0%                         - progn
    9,216   0%                            if
    9,216   0%                          - setq
    9,216   0%                             replace-regexp-in-string
    8,184   0%                 - list
    8,184   0%                  - let*
    8,184   0%                     if
   38,912   0%                - let
   38,912   0%                 + let*
   64,416   0%               + and
--_000_DB9PR08MB6633F71EB92F19628DD1E598A38A9DB9PR08MB6633eurp_-- --_004_DB9PR08MB6633F71EB92F19628DD1E598A38A9DB9PR08MB6633eurp_ Content-Type: text/plain; name="ATT00001.txt" Content-Description: ATT00001.txt Content-Disposition: attachment; filename="ATT00001.txt"; size=593; creation-date="Sat, 13 Feb 2021 01:10:27 GMT"; modification-date="Sat, 13 Feb 2021 01:10:27 GMT" Content-ID: Content-Transfer-Encoding: base64 LS0gDQpbIHN0YXJkaXZpbmVyIF0NCiAgICAgICBJIHRyeSB0byBtYWtlIGV2ZXJ5IHdvcmQgdGVs bCB0aGUgbWVhbmluZyB0aGF0IEkgd2FudCB0byBleHByZXNzLg0KDQogICAgICAgQmxvZzogaHR0 cHM6Ly9zdGFyZGl2aW5lci5naXRodWIuaW8vDQogICAgICAgSVJDKGZyZWVub2RlKTogc3RhcmRp dmluZXIsIE1hdHJpeDogc3RhcmRpdmluZXINCiAgICAgICBHUEc6IEYwOUY2NTBEN0Q2NzQ4MTk4 OTI1OTE0MDFCNURGMUM5NUFFODlBQzMNCg== --_004_DB9PR08MB6633F71EB92F19628DD1E598A38A9DB9PR08MB6633eurp_--