stamblerre / gocode

An autocompletion daemon for the Go programming language
MIT License
394 stars 28 forks source link

Sublime plugin performance #13

Closed jeroenrinzema closed 5 years ago

jeroenrinzema commented 5 years ago

What version of Go are you using (go version)?

go version go1.11.1 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="~/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="~/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/09/3xfd0snx16n18mrlgds_mcjw0000gn/T/go-build223814130=/tmp/go-build -gno-record-gcc-switches -fno-common"

What is the debug output of gocode?

2018/11/13 20:50:22 Got autocompletion request for '/Users/jeroenrinzema/Documents/projects/commander-boilerplate/query/main.go'
2018/11/13 20:50:22 Cursor at: 574
2018/11/13 20:50:22 -------------------------------------------------------
package main

import (
    "net/http"

    "github.com/jeroenrinzema/commander-boilerplate/query/common"
    "github.com/jeroenrinzema/commander-boilerplate/query/controllers"
    "github.com/jeroenrinzema/commander-boilerplate/query/rest"
    _ "github.com/jinzhu/gorm/dialects/postgres"
)

func main() {
    common.OpenDatabase()
    router := common.OpenWebHub()

    router.HandleFunc("/find/{id}", rest.Use(controllers.FindByID, Authentication)).Methods("GET")
    router.HandleFunc("/find/", rest.Use(controllers.FindAll, Authentication)).Methods("GET")

    http.ListenAndServe(":7070", router)
    h#
}

// Authentication validates if the given request is authenticated.
// If the request is not authenticated is a 401 returned.
func Authentication(next http.HandlerFunc) http.HandlerFunc {
    return func(w http.ResponseWriter, r *http.Request) {
        // <- authenticate request and provide the users dataset key
        next.ServeHTTP(w, r)
    }
}
2018/11/13 20:50:22 -------------------------------------------------------
2018/11/13 20:50:22 Elapsed duration: 521.685605ms
2018/11/13 20:50:22 Offset: 0
2018/11/13 20:50:22 Number of candidates found: 1
2018/11/13 20:50:22 Candidates are:
2018/11/13 20:50:22   package http 
2018/11/13 20:50:22 =======================================================

I noticed that the performance of the sublime plugin is quite often "slow" and does not display the typed text until gocode has fetched the results. In the example do i try to write a word as fast as plausible (for ex. http) the first letter will show at once but the rest will follow once gocode is done.

ezgif-5-13be794f747b

stamblerre commented 5 years ago

I didn't write the Sublime plugin, and I don't have the bandwidth to investigate this. If you'd be willing to debug this, I'm happy to accept PRs. Some alternative options you could investigate:

jeroenrinzema commented 5 years ago

I suspect it has to do that all the requests are preformed over a single thread. I will try to investigate the issue and create a PR if i succeed.