Slow autocomplete in Go?

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
zbrown
Posts: 4
Joined: Thu Nov 19, 2015 4:02 am

Slow autocomplete in Go?

Post by zbrown »

Hi,

I'm trying to use Zeus with Go and it seems autocomplete for APIs that are a core part of Go are very slow (>2 seconds after typing "."). I've reproduced this behaviour on two different machines.

Has anyone else seen this or is this a known issue? Any workarounds/fixes? I've tried explicitly creating a tags database from my local Go installation src just to see if it would help but it didn't.

thanks,

Zac
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Slow autocomplete in Go?

Post by jussij »

I suspect this could well be an issue with gocode itself and luckily this is fairly easy to test.

In the Zeus, gocode.py macro script file there is this code:

Code: Select all

def gocodeExecute(fmt):
       .....
       #   set [<name> [<value>]]             list or set config options
       command = "gocode.exe -f=" + fmt + " -in=" + file_name + " autocomplete " + str(cursor)
That macro file is found here:

Code: Select all

C:\Users\<current user>\AppData\Roaming\Xidicone\Zeus\zScript\go_code.py
Change that code by adding a debug message box as follows:

Code: Select all

def gocodeExecute(fmt):
       .....
       #   set [<name> [<value>]]             list or set config options
       command = "gocode.exe -f=" + fmt + " -in=" + file_name + " autocomplete " + str(cursor)

       zeus.message_box(0, command, "Go Code Test")
Now if you replicate the autocomplete issue the message box will display the gocode command that is about to be run.

At this point don't close the message box, but instead use the Ctrl+C command to copy the message details.

Now in a second Zeus session paste that code into an new document, extract the gocode command line, open a new DOS prompt and run that command in the DOS prompt.

If this is a gocode issue the same command will take several seconds to complete inside the DOS prompt.

Cheers Jussi
zbrown
Posts: 4
Joined: Thu Nov 19, 2015 4:02 am

Re: Slow autocomplete in Go?

Post by zbrown »

Hi Jussi,

I'll try out what you've mentioned below. I should note that I have not found the same problems in either Sublime Text's auto-complete with Go or Atom's auto-complete with Go.
jussij wrote:I suspect this could well be an issue with gocode itself and luckily this is fairly easy to test.

... SNIP ...

If this is a gocode issue the same command will take several seconds to complete inside the DOS prompt.

Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Slow autocomplete in Go?

Post by jussij »

I'm trying to use Zeus with Go and it seems autocomplete for APIs that are a core part of Go are very slow
Since this is core information, can you create a simple test file that replicates the issue :?:

For example when I auto-complete on fmt in the example code below, it returns with the results in well under a second:

Code: Select all

package main

import "fmt"

func main() {
	fmt.
}
It could be something particular to Zeus but that does seem rather strange to me :?

I haven't uses Sublime or Atom, but I would have though they too use gocode for auto-completion, so I would have thought the speed would be roughly the same :?

If you post the details of the test above or a sample file that replicates the issue, I'd be happy to take a look.

Could you also check task manager to see how many versions of gocode.exe are running :?:

The Zeus macro is only meant to start gocode.exe if it is not already running (hence the first up pause you get on the first autocomplete).

But I have heard reports of cases where there was more than one instance of gocode running.

Cheers Jussi
zbrown
Posts: 4
Joined: Thu Nov 19, 2015 4:02 am

Re: Slow autocomplete in Go?

Post by zbrown »

Hi,

So I tried your test and it was quite slow the gocode.exe that's installed with Zeus. I tried fetching my own copy of gocode.exe from the git repo and it was much faster.

That said, when I tried replacing the gocode.exe in the Zeus installation folder with the one I fetched, it never really worked at all. Spun the little "busy" spinner a lot, started an instance of gocode.exe but then did nothing :(.

The sample code is nothing special...

Code: Select all

package main

import (
        "syscall"
)

func StupidFunc() {
	derp := syscall.
}
I may try uninstalling and reinstalling to see if that makes a difference at all. Not sure what's up.
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Slow autocomplete in Go?

Post by jussij »

So it does sound like there is something wrong with the gocode.exe :?

I would not do the uninstall/re-install as the only thing you need to change is that single gocode.exe file.

Nothing else should be effecting this.

As another test you could try this version: http://www.zeusedit.com/z300/gocode.zip

That is the gocode.exe that I have installed and it seems to work fine on Windows 10, 64 bit.

Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Slow autocomplete in Go?

Post by jussij »

Scrap that suggestion.

Running your simple test I can also see that massive delay in autocomplete :(

That suggest you are running the same gocode.exe as me.

The version that comes with the Zeus installer was updated to using the latest gocode release only quite recently.

I suspect something in that new release might be broken.

I'll try to test that by trying to locate an earlier version of gocode and repeat your test.

Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Slow autocomplete in Go?

Post by jussij »

This might be a bug in Zeus or the Zeus Go macro :(

Check back in a little while and I might have an answer to this riddle ;)

Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Slow autocomplete in Go?

Post by jussij »

This issue was caused by some sort of deadlock issue in the Zeus gocode Python script.

That Python code was fairly old and was using an older process handling method. Looking into the Python documentation for that API it warns of possible deadlocks.

So I have re-written the script to use the newer, recommended Popen approach and that seems to have fixed the issue.

Here is the new go_code.py file that needs to replace the same file in the zScript folder: http://www.zeusedit.com/z300/go_code.zip

This is the location of the zScript folder:

Code: Select all

C:\Users\<Current User>\AppData\Roaming\Xidicone\Zeus\zScript
And this is the latest version of gocode that works just fine with that new script: http://www.zeusedit.com/z300/gocode.zip

Cheers Jussi
Post Reply