artur-shaik / vim-javacomplete2

DEPRECATED in favor of jc.nvim
Vim License
973 stars 83 forks source link

Slow Completion in class with many methods. #412

Closed StrongerXi closed 5 years ago

StrongerXi commented 5 years ago

Actual behavior (Required!)

Extremely slow auto-complete on an instance of a class with many methods.

Expected behavior (Required!)

Faster completion.

The steps to reproduce actual behavior (Required!)

Here are the profile logs:

Very slow, large class:

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
 2265  12.107335   3.954368  <SNR>83_visitTree()
    8   2.358754   2.355879  javacomplete#server#Communicate()
  117   3.774367   2.323149  <SNR>84_blockStatements()
 1336   3.268295   0.532819  <SNR>84_term3()
 5457   0.780340   0.433434  <SNR>84_nextToken()
 1846              0.395145  javacomplete#util#CleanFQN()
   58   0.261263   0.205261  javacomplete#util#Sort()
    4   0.180483   0.180297  <SNR>17_WinDo()
 6349   0.143578   0.125134  <SNR>84_Log()
 9212              0.111228  <SNR>84_scanChar()
  228   1.408234   0.099632  <SNR>84_statement()
 2258   0.192142   0.092508  <SNR>84_scanIdent()
    9   0.265943   0.083504  javacomplete#complete#complete#SearchMember()
   53              0.070358  java_parser#DecodePos()
20129              0.056002  <SNR>19_MemberCompare()
   67   0.080209   0.053540  <SNR>84_gotoMatchEnd()
 1698   0.334568   0.040583  <SNR>84_ident()
 4103   0.131937   0.038121  <SNR>84_Debug()
    1   0.552479   0.032328  <SNR>79_DoGetMemberList()
 1573   0.331214   0.031224  <SNR>84_accept()

A little slow, simple class:

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
    4   1.898488   1.896769  javacomplete#server#Communicate()
 3702              0.789974  javacomplete#util#CleanFQN()
   56   0.248940   0.196473  javacomplete#util#Sort()
    2   1.100976   0.072463  <SNR>78_DoGetMemberList()
    2   0.679864   0.052893  <SNR>78_UniqDeclaration()
19862              0.052467  <SNR>19_MemberCompare()
    4   0.215868   0.050375  <SNR>78_DoGetMethodList()
 4016              0.046632  <SNR>78_CanAccess()
   11   3.030635   0.032729  <SNR>68_InvokeCompletion()
   12   0.476173   0.026353  javacomplete#complete#complete#SearchMember()
   40   0.064094   0.020890  <SNR>83_visitTree()
    2   1.847129   0.011642  javacomplete#collector#FetchInfoFromServer()
   14   3.744932   0.010264  javacomplete#collector#DoGetClassInfo()
   36              0.008732  <SNR>58_Highlight_Matching_Pair()
   69              0.008327  <SNR>68_Pyeval()
   73              0.007480  316()
  719              0.006956  <SNR>78_GenWord()
   74   0.011963   0.006919  <SNR>84_nextToken()
   13   0.007646   0.006409  <SNR>68_IdentifierFinishedOperations()
    4   0.013033   0.005544  <SNR>78_DoGetFieldList()

Environment (Required!)

Q&A

artur-shaik commented 5 years ago

Can you, please, make simple project to reproduce. I will try to profile it.

StrongerXi commented 5 years ago
import javax.swing.JFrame;

class Foo extends JFrame {
  public Foo() {
  }
}

class Bar {
  public Bar() {
  }
}

On my machine and vim at least, the contrast between "this." or "super." in these two classes' methods is huge. I'm wondering if there's anyway to speed it up.

artur-shaik commented 5 years ago

Very slow, large class

Should say that this is due too vim parser that used to parse opened java file. It should be faster for large files when we move too javaparser lib.

3702 0.789974 javacomplete#util#CleanFQN()

I guess if you enable this feature: g:JavaComplete_UseFQN, it will work little faster.


And you help me find one performance killer. Thank you.