tigersoldier / company-lsp

Company completion backend for lsp-mode
GNU General Public License v3.0
251 stars 26 forks source link

JavaScript completion very slow #109

Closed MatthewZMD closed 5 years ago

MatthewZMD commented 5 years ago

I am using typescript-language-server with the configuration:

(def-package company-lsp
  :defer t
  :config
  (setq company-lsp-cache-candidates 'auto))

The completion is very slow and the ui freezes, this is what I am seeing in profiler-report. Any idea on how to fix it?

- #<compiled 0x3778159>                                 1,008,280,240  34%
 - lsp--parser-on-message                                 874,228,738  30%
  - lsp--read-json                                        788,165,668  27%
   - json-read-from-string                                787,930,180  27%
    - json-read                                           775,152,720  26%
     - json-read-object                                   775,152,720  26%
      - json-read                                         768,059,852  26%
       - json-read-array                                  702,099,111  24%
        - json-read                                       701,243,535  24%
         - json-read-object                               701,243,535  24%
          - json-read                                     390,128,621  13%
           - json-read-object                             353,124,275  12%
              json-new-object                             256,746,336   8%
            + json-read                                    64,283,832   2%
              json-read-string                                 26,099   0%
              json-add-to-object                                3,196   0%
           + json-read-array                               16,065,331   0%
             json-read-number                               3,432,704   0%
            json-new-object                               256,237,608   8%
            json-read-string                                   34,080   0%
            json-add-to-object                                  3,183   0%
       + json-read-object                                  62,205,849   2%
         json-read-number                                     856,356   0%
         json-read-keyword                                    160,876   0%
yyoncho commented 5 years ago

The only solution is to use emacs27 with native parsing.

MatthewZMD commented 5 years ago

@yyoncho is 27's native parsing implemented into lsp already? (ie. upgrading to 27 will fix this immediately)

yyoncho commented 5 years ago

I wouldn't say "fix" but it will speed up json parsing a lot (~4 times). As a side note, make sure that you are not using capf.

MatthewZMD commented 5 years ago

Sure! I'm installing emacs27 and give it a shot

yyoncho commented 5 years ago

@MatthewZMD isnt this solved?