High org-roam load time

Hi, I am new to emacs and org-roam and have set up basic functionalities using codes available in this and other platforms. I do find org-roam to be extremely useful in my note-taking workflow and can see its tremendous potential in organizing and retaining information.
My workflow involves using org-roam-bibTex and org-roam. However, based on my current setup, the load time for org-roam is too high. I used benchmark-init to assess load time and this it showed that org-roam is taking more than 30 seconds to load.

Also, when I load emacs it gives me the following error message, which I think is related to the high load time:

Blockquote Error (use-package): org-roam/:config: Query timeout error: “Query timed out”, 30

Can someone please help me troubleshoot this problem?

Here is the configuration that I am using:

;;========== Org-roam Configuration======

(use-package org-roam
  :ensure t
  (org-roam-directory (file-truename "C:/Doc/roam"))
  (org-roam-completion-everywhere t)
  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
         ("C-c n g" . org-roam-graph)
         ("C-c n c" . org-roam-capture)
	 ("C-c n r" . org-roam-node-random)
	 (:map org-mode-map
	       ("C-c n i" . org-roam-node-insert)
	       ("C-c n o" . org-id-get-create)
	       ("C-c n t" . org-roam-tag-add)
	       ("C-c n a" . org-roam-alias-add)
	       ("C-c n m". completion-at-point)
	       ("C-c n l" . org-roam-buffer-toggle)))

  (setq org-roam-capture-templates
      '(("i" "new_ideas" plain "%?"
         :if-new (file+head "research/new_ideas/${title}.org" "#+title: ${title}\n")
         :immediate-finish t
         :unnarrowed t)
	("n" "annotations" plain "%?"
         (file+head "research/annotations/${title}.org" "#+title: ${title}\n")
         :immediate-finish t
         :unnarrowed t)	
	("m" "my_pub" plain "%?"
         (file+head "research/my_pub/${title}.org" "#+title: ${title}\n#+filetags: :article:\n")
         :immediate-finish t
         :unnarrowed t)
(setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))

;; ===== Configure Deft ========

(use-package deft
    (setq deft-directory "C:/Dey/memories"
	  deft-extensions '("txt" "tex" "org")
	  deft-recursive t
          deft-strip-summary-regexp ":PROPERTIES:\n\\(.+\n\\)+:END:\n"
          deft-use-filename-as-title t)
    ("C-c n d" . deft))

;; ====== Configure org-roam-ui =======
(use-package org-roam-ui
  :ensure t
  ("C-c n g" . org-roam-ui-mode))

;;========== BibTex Setup ======

;;Fine tuning BibTex mode

;;; Allow org-ref to find pdfs - basically align filenames in someway
(setq org-ref-get-pdf-filename-function #'org-ref-get-pdf-filename-helm-bibtex)

;;; Spell checking (requires the ispell software)
(add-hook 'bibtex-mode-hook 'flyspell-mode)

;;; Change fields and format
(setq bibtex-user-optional-fields '(("keywords" "Keywords to describe the entry" "")
                                      ("file" "Link to document file." ":"))
        bibtex-align-at-equal-sign t)

;; Setup BibLaTex
(setq bibtex-dialect 'biblatex)

;; Assign File Locations
(setq bib-files-directory (directory-files "G:/My Drive/Research" t "^[A-Z|a-z].+.bib$")
        pdf-files-directory "G:/My Drive/Zotero")

;; Configure Helm BibTeX to manage bibliographies, read documents and take notes

(use-package helm-bibtex
    (setq bibtex-completion-bibliography bib-files-directory
          bibtex-completion-library-path pdf-files-directory
          bibtex-completion-pdf-field "File"
          bibtex-completion-notes-path org-directory
          bibtex-completion-additional-search-fields '(keywords))
    (("C-c n c" . helm-bibtex)))

;; configure org-ref

(require 'org-ref)
(require 'org-ref-helm)
(require 'org-ref-ivy)
(require 'org-ref-bibtex)

(setq org-ref-insert-link-function 'org-ref-insert-link-hydra/body
      org-ref-insert-cite-function 'org-ref-cite-insert-ivy
      org-ref-insert-label-function 'org-ref-insert-label-link
      org-ref-insert-ref-function 'org-ref-insert-ref-link
      org-ref-cite-onclick-function (lambda (_) (org-ref-citation-hydra/body)))

(define-key org-mode-map (kbd "C-c i") 'org-ref-insert-link)

;; Configure org-roam BibTex
(use-package org-roam-bibtex
    :after (org-roam helm-bibtex)
    :bind (:map org-mode-map ("C-c n b" . orb-note-actions))
    (require 'org-ref))

Just for context, I do not understand codes that well and the code above is mostly copied from multiple sources and somehow made to work for my workflow (as one can tell perhaps :smiley: ). I will really appreciate any tips on optimizing the code above :slight_smile:

You are using Windows? Is this folder local or somewhere remote? If remote, that may be a dominant factor for the loading time.

Other than the loading time, is Org-roam working?

How may nodes do you have? If it’s more than 10K, it might be just normal (but not sure).

You only need to do the first one. It includes enable. I don’t think it’s likely part of the loading problem, though.

Thanks @nobiot for the quick revert. Taking that second line out fixed the load-time problem.

I have a related question about storing org-roam files on my PC (I use windows) vs remotely.

I am just starting to use org-roam and do not have a lot of files yet. I am planning to move from a PC to a Mac later this year and was wondering if my nodes would be affected by the change. For examples, would the links between nodes still work if I move my org-roam folder from a PC to a Mac? Is storing files remotely e.g. on Google Drive a more sustainable solution for situations like these?


Great. This is good news. I can’t explain why, though, and am a bit puzzled. But the result is great. Apologies if I mislead you.

It should not. I often move files between my Windows and Linux machines. I used to use Dropbox to sync files in Org-roam directory, too. Either way, I have had no issue. That’s the benefit of text files. I also used macOS in the past; I copied and pasted all the files to Windows and Linux – no issue.

Google Drive can be used to sync between machines. I just happen have used Dropbox in the past. These cloud storage applications should be just an additional convenience, and should not affect your use of Emacs and Org-roam.

Technically, between Windows and other OS, you may experience the difference about line ending style (typically, Emacs on Mac or Linux may display text files created in Windows with the end of the line as “^M”) but this should not affect the content of the notes and Org-roam.

1 Like

By “remote”, I meant files placed in a file server in the network you have access to, not Google Drive – it stores files locally and have a duplicates on the cloud storage. So for the purpose of Emacs, the files are accessed locally.

You have “TRAMP” in your config, so I thought you store your org-roam files in some file server – this can be slow…

I see. Tramp is in fact the next item that is slowing the load time. I did not install it myself, but I do use OneDrive to back my files on the cloud. So maybe its picking that up somehow?

Emacs does not do anything (usually) unless you tell it to. Maybe your bibtex files in drive G is related but i can’t tell. I don’t think I use TRAMP.

1 Like