spectacles / CodeComplice

CodeIntel for Sublime Text 2 / 3
Other
167 stars 18 forks source link

Timeout while resolving completions #14

Closed mrliptontea closed 9 years ago

mrliptontea commented 9 years ago

Hello there,

When I'm working with somewhat bigger code base, it's easy to cause a timeout. Even after I excluded framework and all external libraries there's still chance to make the script timeout.

I suggest that timeouts should be configurable.

spectacles commented 9 years ago

I would like to help you with your problem! Are you using ST 2 or 3? For this somewhat bigger project, i suggest strongly you define a dedicated codeintel_database_dir in your sublime-project file (read up the 'configuring' section). Make sure it gets created, when you trigger some completions. Once the indexing has finished, please go to your Sublime Command Palette and execute the command "CodeComplice: Dump Import Direrctories". This will create a "import_dir_stats" directory in your database dir. Inside this directory you will find files, that list you import directories for specific programming languages. You may send the contents of those files here!

Have a nice day

mrliptontea commented 9 years ago

I'm using ST3, on Win 8.1 x64, i7 processor, SSD drive, so the system is quite fast. I admit, I forgot about project specific configuration. Thanks, this will come in handy.

So, my project configuration is as below:

"codeintel_settings":
{
    "codeintel_database_dir": "~/.codeintel/databases/pst",
    "codeintel_language_settings": {
        "PHP": {
            "codeintel_scan_extra_dir"         : [],
            "codeintel_scan_files_in_project"  : true,
            "codeintel_max_recursive_dir_depth": 10,
            "codeintel_scan_exclude_dir"       : [
                "Doctrine", "Danceric", "OLE", "PHPExcel", "Spreadsheet",
                "tcpdf", "Zend", "ZendX", "ZFDebug"
            ]
        }
    }
}

I've triggered some completion, and this appeared in the console, then I pressed Ctrl+Shift+Space again and again:

Timeout while resolving completions!
current triggername: 'php-calltip-call-signature'
processing `PHP': please wait...
Doing CodeIntel for 'PHP' (hold on)...
current triggername: 'php-calltip-call-signature'

After the second attempt, the popup was shown, but the first one stopped at the timeout.

The dump file: http://pastie.org/private/f7vdud8bmveyrlxpv3fra As you can see it's not that big code base, in each folder there are just a few files, although it's not the entire project, it was just after clean reindexing, and triggering that one completion.

I wonder - would it be better to include my project folder(s) in codeintel_scan_extra_dir and set codeintel_scan_files_in_project to false?

Thanks for your help and awesome work with this package!

pschneider commented 9 years ago

I get this even with the project specific dir quite often. Also i realise that CodeComplice seems to scan every directory over and over again for each triggered completion rather than using the created index. First i thought this was caused by different projects using the same database dir but it also happens with the project specific databases. On the other hand sometimes it jumps really fast into the clicked class.

wizza-smile commented 9 years ago

After the second attempt, the popup was shown, but the first one stopped at the timeout.

@mrliptontea That is because the index/database is only half of the story. What makes CodeIntel come to speed is a lot of caching. Whenever you are starting Sublime, those caches will be empty at first. That is why the first trigger might timeout, but after that it works.

Compare with this issue: https://github.com/SublimeCodeIntel/SublimeCodeIntel/issues/326

The guy has mostly excellent times for his completions (around 40ms). Only at the beginning has he a 20s timeout. Notice the last line in the posted logfile. It says

codeintel-message: This buffer is configured with 3129 PHP import dirs: this may result in poor completion performance

Komodo recommends around 100 import directories. So no wonder he is getting a big timeout at first.

Keep an eye on you dump-files created with "CodeComplice: Dump Import Directories". Make sure only directories you want get scanned. Also: If in your configs you provided a path to a php interpreter executable, CodeComplice will attempt to scan your php import libs automatically! There can be A LOT of files in there, so make sure only things get scanned you need, stay around 100/200 import dirs!!

spectacles commented 9 years ago

Also i realise that CodeComplice seems to scan every directory over and over again for each triggered completion rather than using the created index.

@venox what makes you sure this is happening?

spectacles commented 9 years ago

Since nobody replies, I will close this issue. Please re-open if the insights I have given are not sufficient to explain the behavior of CodeComplice in your case, and I will investigate further!

Nikolthor commented 3 years ago

Open SublimeCodeIntel.py in plugin dir. Find this part:

try:
    if 'cplns' in forms:
        if trg and trg.form == TRG_FORM_CPLN:
            cplns = buf.cplns_from_trg(trg, ctlr=ctlr, timeout=20)
    if 'calltips' in forms:
        if trg and trg.form == TRG_FORM_CALLTIP:
            calltips = buf.calltips_from_trg(trg, ctlr=ctlr, timeout=20)
    if 'defns' in forms:
        if defn_trg and defn_trg.form == TRG_FORM_DEFN:
            defns = buf.defns_from_trg(defn_trg, ctlr=ctlr, timeout=20)
except EvalTimeout:
    logger(view, 'info', "Timeout while resolving completions!")
finally:

Set timeout more than 20 and restart sublime.