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/mobile: gomobile bind takes too long #28096

Open
vickyramachandra opened this issue Oct 9, 2018 · 11 comments

Comments

@vickyramachandra
Copy link

@vickyramachandra vickyramachandra commented Oct 9, 2018

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

go version go1.10.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/user/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/user/Documents/Freshdesk/golang"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.3/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/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/y8/ylh63k1106ldg8t7q3jrl701s3tf0r/T/go-build694332607=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I use gomobile for building .aar and .framework for Android and iOS respectively. The gomobile bind -target=android/ios usually takes about 10 to 15 seconds. But off late, the process easily takes more than 3 minutes

What did you expect to see?

Less build time (~10 to 15 secs)

What did you see instead?

Too long (> 3 mins)

@gopherbot gopherbot added this to the Unreleased milestone Oct 9, 2018
@gopherbot gopherbot added the mobile label Oct 9, 2018
@vickyramachandra

This comment has been minimized.

Copy link
Author

@vickyramachandra vickyramachandra commented Oct 9, 2018

@eliasnaur

This comment has been minimized.

Copy link
Contributor

@eliasnaur eliasnaur commented Oct 9, 2018

What's the steps for reproducing the problem?

@vickyramachandra

This comment has been minimized.

Copy link
Author

@vickyramachandra vickyramachandra commented Oct 10, 2018

Just get the latest version of gomobile by go get golang.org/x/mobile/cmd/gomobile and gomobile init. Now try to run the command on a sample.go

@eliasnaur

This comment has been minimized.

Copy link
Contributor

@eliasnaur eliasnaur commented Oct 10, 2018

I can't reproduce the problem. I made a trivial change to example/bind/hello/hello.go to avoid caching and ran

$ time gomobile bind golang.org/x/mobile/example/bind/hello

real	0m8,942s
user	0m7,954s
sys	0m2,384s

and it completed in under 10 seconds.

Note that because of the new cmd/go caching in Go 1.10 (and 1.11) the first gomobile bind probably takes quite a while.

@vickyramachandra

This comment has been minimized.

Copy link
Author

@vickyramachandra vickyramachandra commented Oct 10, 2018

Hey Elias,
First time when i ran it for example/bind/hello/hello.go, i got the following

 real	1m56.577s
 user	0m28.475s
 sys	0m11.957s

and the subsequent one showed this

 real	1m37.963s
 user	0m9.844s
 sys	0m7.439s
@eliasnaur

This comment has been minimized.

Copy link
Contributor

@eliasnaur eliasnaur commented Oct 10, 2018

I don't know why, sorry. It's suspicious that real time is more than a minute yet so little time is spent in user and kernel mode.

@fl0cke

This comment has been minimized.

Copy link

@fl0cke fl0cke commented Jan 11, 2019

Any progress on this? My main issue right now is that gomobile bind recompiles everyhting even if the go sources haven't changed, adding at least 10s to every build in android studio. A build cache / incremental builds would help tremendously in this case.

@vickyramachandra

This comment has been minimized.

Copy link
Author

@vickyramachandra vickyramachandra commented Jan 11, 2019

Unfortunately no. I'll happily take 10s. But its way more than that. My friend @arunkumar9t2 has done some incremental build solution prototype. Hope he can help!

@eliasnaur

This comment has been minimized.

Copy link
Contributor

@eliasnaur eliasnaur commented Jan 11, 2019

I suppose someone has to profile gomobile and figure out an explanation for the discrepancy between my 10s and @vickyramachandra's 2m. The gomobile -x flag might be useful.

Also note that the gradle plugin is no longer supported, so a more clumsy but direct workaround is to manually run gomobile only when the Go code has changed.

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Oct 14, 2019

@vickyramachandra - Just wanted to circle back and check in on this. Are you still facing this issue ? Could you try with gomobile built with 1.13 and let us know if there is any difference ?

@arunkumar9t2

This comment has been minimized.

Copy link

@arunkumar9t2 arunkumar9t2 commented Oct 14, 2019

Me and @vickyramachandra no longer work on the project, let me check with my peers to see if it has improved.

In the mean time, we built our own Gradle plugin to build go sources only when our sources have changed, this helped a lot in reducing build times when we were not editing go files.

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