gtags very slow in Emacs

I am using gnu global in emacs, everything is ok, but command "gtags-find-tag" search is too slow that cannot bear. only this command is very slow, the others like "gtags-find-rtag" is normal I think. I delete other config such as cedet, so that exclude these effect, but this issue is still exist. Do I miss some config steps of global or emacs? or anyone in other platform(linux) has this issue?

my Emacs is emacs for Mac OSX version is 24.3, GNU global is 6.2.8, and my config file is

(add-to-list 'load-path (expand-file-name "~/.emacs.d"))
(setq load-path (cons "/Users/xxx/.emacs.d/gtags.el" load-path))
(autoload 'gtags-mode "gtags" "" t)
(add-hook 'c-mode-hook
   (lambda ()
     (gtags-mode t)


  • I don't use Global (I do keep meaning to try it), but looking at the code, gtags-find-tag and gtags-find-rtag are very similar functions.

    I presume the difference must either be in the completing-read phase, or the find phase, both of which are calling Global.

    In the completing-read, 'gtags' passes the option -c, while 'grtags' passes -cr

    In the find phase, 'gtags' passes -x, while 'grtags' passes -xr.

    I would firstly try to establish whether it is faster outside of Emacs than it is inside it. The above might be sufficient for you to test this, but you should be able to figure out the exact commands being used by using M-x debug-on-entry RET call-process RET (which you can subsequently cancel with M-x cancel-debug-on-entry), and then running the gtags functions and seeing which arguments appear in the stack trace for that function call.

    If you can't make heads or tails of the stack trace, try copying and pasting it into your question.


    Based on the information from the comments, it's appears that it's the case-insensitivity argument which is, for some reason, slowing things down to an unreasonable degree.

    You should be able to disable that behaviour here:

    M-x customize-variable RET gtags-ignore-case RET