Re: company-semantic attempts to uncompress and parse tons of .el.gz files

Eric Ludlam <[email protected]> Sat, 29 Apr 2017 17:53:45 -0400
Newsgroups gmane.emacs.semantic
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------BBAB18EAEF388444BCB9A214
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit

On 04/24/2017 11:37 AM, Justin Seeley wrote:
> If I have company-mode and semantic mode turned on in an elisp file
> without any further customisation, typing a word frequently triggers
> parsing of compressed packgeas.
>
> The problem is reported multiple times here:
> https://github.com/company-mode/company-mode/issues/525
>
> Could someone help solving the problem?

I tried replicating this without company mode. (I have Emacs 24.5, and 
use CEDET from the sourceforge git repository)

By putting in:

(package-

and doing M-x semantic-analyze-possible-completions RET

it will load some .el.gz files that have symbols starting with 
'pacakge-'.   If company is doing this when there is only one character, 
there would be a lot of files to load.  In theory however, after a few 
such symbols, it would stop loading all those files.

I chased the requirement for loading the matched files, and sadly it is 
core to the functionality of binding discovered tags (from the Emacs 
internal symbol search) to a file.  The low level 'normalize' function 
doesn't know what the results will be used for, and several use cases 
(such as jumping to a symbol) needs the file name, though completion 
doesn't.

One could assume that no-one would use semantic for jumping to a lisp 
file since emacs does a fine job of it already.  I've attached a patch 
which matches the sourceforge version of semantic that disables loading 
of the files during 'normalization'.  This will mean some features of 
semantic that need to jump into those files won't work.  It will however 
let all the old completion features keep going just fine.

If this is an acceptable compromise, it is probably possible to make a 
better compromise to at least associate a tag with a file without 
loading the file.

Hope this helps.
Eric

--------------BBAB18EAEF388444BCB9A214
Content-Type: text/x-patch;
 name="semantic-db-el.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="semantic-db-el.patch"

diff --git a/lisp/cedet/semantic/db-el.el b/lisp/cedet/semantic/db-el.el
index f2b7584b..1ba48b3e 100644
--- a/lisp/cedet/semantic/db-el.el
+++ b/lisp/cedet/semantic/db-el.el
@@ -138,6 +138,11 @@ For Emacs Lisp system DB, there isn't one."
     ;; There is no promise to have files associated.
     (nreverse newtags)))
 
+(defcustom semanticdb-el-dont-parse-files-during-normilzation t
+  "When semantic searches Emacs' symbol table, don't parse .el files during normalization.
+Normalization is a process for during an internal Emacs symbol into a tag
+associated with a specific file where it was declared.")
+
 (defmethod semanticdb-normalize-one-tag ((obj semanticdb-table-emacs-lisp) tag)
   "Convert one TAG, originating from Emacs OBJ, into standardized form.
 If Emacs cannot resolve this symbol to a particular file, then return nil."
@@ -156,7 +161,8 @@ If Emacs cannot resolve this symbol to a particular file, then return nil."
 		 ;; Older [X]Emacs don't have a 2nd argument.
 		 (error (symbol-file sym))))
 	 )
-    (if (or (not file) (not (file-exists-p file)))
+    (if (or (not file) (not (file-exists-p file))
+	    semanticdb-el-dont-parse-files-during-normilzation)
 	;; The file didn't exist.  Return nil.
 	;; We can't normalize this tag.  Fake it out.
 	(cons obj tag)

--------------BBAB18EAEF388444BCB9A214
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--------------BBAB18EAEF388444BCB9A214
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
cedet-semantic mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cedet-semantic

--------------BBAB18EAEF388444BCB9A214--