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

Closed
vickyramachandra opened this issue Oct 9, 2018 · 12 comments
Closed

x/mobile: gomobile bind takes too long #28096

vickyramachandra opened this issue Oct 9, 2018 · 12 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@vickyramachandra
Copy link

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 Android, iOS, and x/mobile label Oct 9, 2018
@vickyramachandra
Copy link
Author

cc @eliasnaur and @hyangah

@eliasnaur
Copy link
Contributor

What's the steps for reproducing the problem?

@vickyramachandra
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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
Copy link

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Contributor

@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 ?

@agnivade agnivade added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 14, 2019
@arunkumar9t2
Copy link

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.

@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants