Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/cmd/gorename: takes 20s+ for a package that imports cgo package #26821

Open
ysmolsky opened this issue Aug 6, 2018 · 1 comment

Comments

@ysmolsky
Copy link
Member

commented Aug 6, 2018

gorename is not usable for the program pasted below. That program imports a package that is build in cgo mode.
The reason for this is the way gorename deals with cgo file. It processes them with the co preprocessor. The example below leads to this command being run (that takes 24 seconds):
go tool cgo -objdir /var/folders/km/50gy6_q557v6_7vxbf9b29v00000gn/T/github.com_veandco_go-sdl2_sdl_C598351148 -- -D_THREAD_SAFE -I/opt/local/include/SDL2 -I /var/folders/km/50gy6_q557v6_7vxbf9b29v00000gn/T/github.com_veandco_go-sdl2_sdl_C598351148 audio.go blendmode.go clipboard.go cpuinfo.go endian.go error.go events.go filesystem.go gamecontroller.go gesture.go haptic.go hints.go joystick.go keyboard.go keycode.go loadso.go log.go mouse.go mutex.go pixels.go power.go rect.go render.go rwops.go scancode.go sdl.go sdl_cgo.go surface.go sysrender.go syswm.go timer.go touch.go version.go video.go

It's been called from parsePackageFiles of x/tools/go/loader/loader.go

I think it's a problem of go/loader.

@alandonovan, is there a way to fix this? I would be glad to tackle it.

% cat main.go
package main

import (
	"github.com/veandco/go-sdl2/sdl"
)

const w = 800
const h = 600

func main() {
	println(sdl.INIT_VIDEO)
}

% gtime gorename -v -offset=main.go:#66 -to A
gorename: Loading package: gorenameclib
gorename: Updating package gorenameclib

24.36user 4.18system 0:25.95elapsed 110%CPU (0avgtext+0avgdata 310689792maxresident)k
0inputs+55outputs (1major+1165748minor)pagefaults 0swaps

% go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/thorn/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/thorn/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/thorn/golang"
GOTMPDIR=""
GOTOOLDIR="/Users/thorn/golang/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/km/50gy6_q557v6_7vxbf9b29v00000gn/T/go-build052892133=/tmp/go-build -gno-record-gcc-switches -fno-common"

@gopherbot gopherbot added this to the Unreleased milestone Aug 6, 2018

@ysmolsky ysmolsky changed the title x/tools/cmd/gorename: takes long to rename in a package that imports unsafe package with C bindings x/tools/cmd/gorename: takes 20s+ for a package that imports cgo package Aug 6, 2018

@ysmolsky

This comment has been minimized.

Copy link
Member Author

commented Sep 18, 2018

Interesting, that it happened on that particular packaged mentioned above. I worked with other CGO packages and it was blazing fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.