Improving performance
This is to record and serve as a reminder for a issue raised in Org-mode mailing list.
Source: https://list.orgmode.org/878rxrdu46.fsf@localhost/
Ihor Radchenko has also kindly provided some test files that can be used to investigate the issue and advice.
I noticed that you are using overlays in text-clone. It may potentially cause slowdown in large Org buffers. Of course, it does not mean that org-transclusion should not be accepted. Just something that may be optimised.
A clarification: The example files I provided do not demonstrate overlay-related slowdown. Transclusion is slow there because of unrelated reasons and long before the file size where overlays become an issue.
CPU profiler report for the example file from my last email (reply to the linked email) is below:
1867 54% - funcall-interactively
1858 53% - org-transclusion-add-all
1678 48% - org-transclusion-add
867 25% - org-transclusion-content-insert
400 11% - org-transclusion-content-format-org
400 11% + org-mode
377 10% + org-mode
70 2% + org-transclusion-content-highest-org-headline
399 11% - org-transclusion-wrap-path-to-link
349 10% + org-mode
20 0% + org-element-context
20 0% org-fold-core--fix-folded-region
10 0% + org-element--cache-after-change
363 10% - org-transclusion-add-org-id
300 8% - org-transclusion-content-org-marker
290 8% - org-transclusion-content-org-buffer-or-element
240 6% + org-element-parse-buffer
30 0% + org-element-interpret-data
20 0% + org-element-context
63 1% + org-id-find
39 1% + org-transclusion-keyword-remove
10 0% + org-transclusion-keyword-string-to-plist
180 5% + org-transclusion-keyword-string-to-plist