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

cmd/go: feature request: timing for each component built #16375

Closed
kokizzu opened this issue Jul 14, 2016 · 5 comments
Closed

cmd/go: feature request: timing for each component built #16375

kokizzu opened this issue Jul 14, 2016 · 5 comments

Comments

@kokizzu
Copy link

kokizzu commented Jul 14, 2016

When doing go build -i -x, it outputs something like this

cd /home/asd/MEGA/go/src/Test1
/usr/lib/go/pkg/tool/linux_amd64/compile -o $WORK/Test1.a -trimpath $WORK -p main -complete -buildid 6d6a870e9806648c308d01500862acf24009cb43 -D _/home/asd/MEGA/go/src/Test1 -I $WORK -I /home/asd/MEGA/go/pkg/linux_amd64 -pack ./assets.go ./oauth.go ./router.go ./server.go
cd .
/usr/lib/go/pkg/tool/linux_amd64/link -o $WORK/Test1/_obj/exe/a.out -L $WORK -L /home/asd/MEGA/go/pkg/linux_amd64 -extld=gcc -buildmode=exe -buildid=6d6a870e9806648c308d01500862acf24009cb43 $WORK/Test1.a
mkdir -p /tmp/
mv $WORK/Test1/_obj/exe/a.out /tmp/gin-bin

it would be nice to see the timing for each execution:

[1 ms] cd /home/asd/MEGA/go/src/Test1
[124 ms] /usr/lib/go/pkg/tool/linux_amd64/compile -o $WORK/Test1.a -trimpath $WORK -p main -complete -buildid 6d6a870e9806648c308d01500862acf24009cb43 -D _/home/asd/MEGA/go/src/Test1 -I $WORK -I /home/asd/MEGA/go/pkg/linux_amd64 -pack ./assets.go ./oauth.go ./router.go ./server.go
[1 ms] cd .
[9124 ms] /usr/lib/go/pkg/tool/linux_amd64/link -o $WORK/Test1/_obj/exe/a.out -L $WORK -L /home/asd/MEGA/go/pkg/linux_amd64 -extld=gcc -buildmode=exe -buildid=6d6a870e9806648c308d01500862acf24009cb43 $WORK/Test1.a
[1 ms] mkdir -p /tmp/
[1 ms] mv $WORK/Test1/_obj/exe/a.out /tmp/gin-bin

so I could see which package that are slow to rebuild.

@kokizzu kokizzu changed the title Feature request: timing for each component built cmd/go/build.go: feature request: timing for each component built Jul 14, 2016
@ianlancetaylor ianlancetaylor changed the title cmd/go/build.go: feature request: timing for each component built cmd/go: feature request: timing for each component built Jul 14, 2016
@kokizzu
Copy link
Author

kokizzu commented Jul 14, 2016

After modifying the build.go, now i know that the slow compiling problem in my project is some package keep being recompiled even when there are no changes..

go build -i -v

Test1/db/model
[2198.86] /usr/lib/go/pkg/tool/linux_amd64/compile 
Test1/ajax
Test1/db/transform
[423.75] /usr/lib/go/pkg/tool/linux_amd64/compile 
[3115.87] /usr/lib/go/pkg/tool/linux_amd64/compile 
Test1/db/migrate
[883.56] /usr/lib/go/pkg/tool/linux_amd64/compile 
Test1/page
[1003.04] /usr/lib/go/pkg/tool/linux_amd64/compile 
Test1
[352.51] /usr/lib/go/pkg/tool/linux_amd64/compile 
[2618.77] /usr/lib/go/pkg/tool/linux_amd64/link 

db/migrate and db/transform rarely used and it increase the compiling duration by 4 seconds, after removing those packages:

Test1/db/model
[2149.55] /usr/lib/go/pkg/tool/linux_amd64/compile 
Test1/ajax
Test1/page
[1188.99] /usr/lib/go/pkg/tool/linux_amd64/compile 
[3655.12] /usr/lib/go/pkg/tool/linux_amd64/compile 
Test1
[481.60] /usr/lib/go/pkg/tool/linux_amd64/compile 
[3028.78] /usr/lib/go/pkg/tool/linux_amd64/link 

this is just an example how useful is to show the timing for each package.

        start := time.Now()
        ...
        err := cmd.Run()
        ...
        elapsed := float64(time.Since(start).Nanoseconds())
        fmt.Printf("[%.2f] %s \n", ...

@josharian
Copy link
Contributor

Something like #15736?

@kokizzu
Copy link
Author

kokizzu commented Jul 14, 2016

ah yeah XD so this is a duplicate..

@josharian
Copy link
Contributor

Cool. Hopefully -trace support will land in 1.8.

@davecheney
Copy link
Contributor

Have a look at the toolexec flag, you can use that to inject /use/bin/time
as a prefix to the command.

Also, the -v flag will print each package as it compiled, this should give
you a rough ballpark of the slow to compile packages.

Lastly. If you are concerned about compilation time, prefer go install to
go build.

On Thu, 14 Jul 2016, 09:03 Kiswono Prayogo notifications@github.com wrote:

When doing go build -i -x, it outputs something like this

[go] cd /home/asd/MEGA/go/src/Test1
[go] /usr/lib/go/pkg/tool/linux_amd64/compile -o $WORK/Test1.a -trimpath $WORK -p main -complete -buildid 6d6a870e9806648c308d01500862acf24009cb43 -D _/home/asd/MEGA/go/src/Test1 -I $WORK -I /home/asd/MEGA/go/pkg/linux_amd64 -pack ./assets.go ./oauth.go ./router.go ./server.go
[go] cd .
[go] /usr/lib/go/pkg/tool/linux_amd64/link -o $WORK/Test1/_obj/exe/a.out -L $WORK -L /home/asd/MEGA/go/pkg/linux_amd64 -extld=gcc -buildmode=exe -buildid=6d6a870e9806648c308d01500862acf24009cb43 $WORK/Test1.a
[go] mkdir -p /tmp/
[go] mv $WORK/Test1/_obj/exe/a.out /tmp/gin-bin

it would be nice to see the timing for each execution:

[1 ms] cd /home/asd/MEGA/go/src/Test1
[124 ms] /usr/lib/go/pkg/tool/linux_amd64/compile -o $WORK/Test1.a
-trimpath $WORK -p main -complete -buildid
6d6a870e9806648c308d01500862acf24009cb43 -D _/home/asd/MEGA/go/src/Test1 -I
$WORK -I /home/asd/MEGA/go/pkg/linux_amd64 -pack ./assets.go ./oauth.go
./router.go ./server.go
[1 ms] cd .
[9124 ms] /usr/lib/go/pkg/tool/linux_amd64/link -o
$WORK/Test1/_obj/exe/a.out -L $WORK -L /home/asd/MEGA/go/pkg/linux_amd64
-extld=gcc -buildmode=exe -buildid=6d6a870e9806648c308d01500862acf24009cb43
$WORK/Test1.a
[1 ms] mkdir -p /tmp/
[1 ms] mv $WORK/Test1/_obj/exe/a.out /tmp/gin-bin

so I could see which package that are slow to rebuild.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#16375, or mute the thread
https://github.com/notifications/unsubscribe/AAAcA-34NJQgClh0P9aKOG2DSd4aSJzgks5qVk-mgaJpZM4JMhv0
.

@golang golang locked and limited conversation to collaborators Jul 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants