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/compile: share statictmp #19818

Open
QuestionPython opened this Issue Apr 1, 2017 · 5 comments

Comments

Projects
None yet
6 participants
@QuestionPython

QuestionPython commented Apr 1, 2017

Hello,

i have 2 file,
one ==> a go file with 10000 time repeat : fmt.Print("...........\n")
two ==> a c(gcc) file with 10000 time repeat : printf("...........\n");

size of output c is about 200kb.
size of output go is 50mb.(also long time need for build...)

@ALTree

This comment has been minimized.

Member

ALTree commented Apr 1, 2017

I've tried with a file with 10k fmt.Println("0123456789!!!") and while I can reproduce the issue, the tip compiler behaves much better than the 1.8 compiler.

go1.8:

271.93user 1.12system 2:10.43elapsed 209%CPU (0avgtext+0avgdata 702816maxresident)k

tip:

23.48user 0.30system 0:23.02elapsed 103%CPU (0avgtext+0avgdata 347308maxresident)k

so tip is more than 10x faster and also uses half the RAM. The tip executable is also "only" 28M (vs 51M for go1.8). Still quite big.

@randall77

This comment has been minimized.

Contributor

randall77 commented Apr 1, 2017

A couple of things I noticed in this example.

  1. We're using a separate autotmp for each call for the ... args. We could use the same one repeatedly. (We already know it doesn't escape.)
  2. Each string gets its own statictmp for converting it to an interface. We could share them. (I thought we already did?)

@josharian

@josharian

This comment has been minimized.

Contributor

josharian commented Apr 1, 2017

We share the string data, but not (yet) the statictmp.

@bradfitz bradfitz changed the title from Size of Compiled is Big! to cmd/compile: share statictmp Apr 1, 2017

@bradfitz bradfitz added the Performance label Apr 1, 2017

@bradfitz bradfitz added this to the Unplanned milestone Apr 1, 2017

@QuestionPython

This comment has been minimized.

QuestionPython commented Apr 1, 2017

my go file as input:

package main
import (
    "fmt"
    //"html"
    //"log"
    //"net/http"
)
func main() {
fmt.Print("hello123456789\n");
fmt.Print("hello123456789\n");
fmt.Print("hello123456789\n");
.
.
.
.
}

my c file as input:

#include<stdio.h>
int main()
{
	printf("hello123456789\n");
	printf("hello123456789\n");
.
.
.
}

my for c use gcc.
also for go use go1.8.
my os ==> ubuntu

@gopherbot

This comment has been minimized.

gopherbot commented Apr 29, 2017

CL https://golang.org/cl/42170 mentions this issue.

josharian added a commit to josharian/go that referenced this issue May 2, 2017

cmd/compile: make some static constants content-addressable
DO NOT SUBMIT

[generates broken code]

To avoid allocating when placing a constant in an interface,
we generate a static symbol containing that constant's value.

However, constants tend to re-occur.
This CL makes the symbols content-addressable,
so that repeated constants can share them.

For the code like that in golang#19818 (1024 fmt.Printlns in a main),
this reduces the object file size by 10%.

name  old time/op       new time/op       delta
Pkg         161ms ± 2%        147ms ± 2%   -8.28%  (p=0.008 n=5+5)

name  old user-time/op  new user-time/op  delta
Pkg         194ms ± 5%        180ms ± 4%   -7.06%  (p=0.016 n=5+5)

name  old alloc/op      new alloc/op      delta
Pkg        36.2MB ± 0%       34.7MB ± 0%   -4.09%  (p=0.008 n=5+5)

name  old allocs/op     new allocs/op     delta
Pkg          191k ± 1%         179k ± 0%   -6.43%  (p=0.008 n=5+5)

name  old object-bytes  new object-bytes  delta
Pkg          462k ± 0%         415k ± 0%  -10.18%  (p=0.008 n=5+5)

name  old export-bytes  new export-bytes  delta
Pkg          51.0 ± 0%         51.0 ± 0%     ~     (all equal)


Change-Id: I6e04f52b41fd77a2181466160795f35d13b491b4

josharian added a commit to josharian/go that referenced this issue May 10, 2017

cmd/compile: make some static constants content-addressable
DO NOT SUBMIT

[generates broken code]

To avoid allocating when placing a constant in an interface,
we generate a static symbol containing that constant's value.

However, constants tend to re-occur.
This CL makes the symbols content-addressable,
so that repeated constants can share them.

For code like that in golang#19818 (1024 fmt.Printlns in a main),
this reduces the object file size by 10%.

name  old time/op       new time/op       delta
Pkg         161ms ± 2%        147ms ± 2%   -8.28%  (p=0.008 n=5+5)

name  old user-time/op  new user-time/op  delta
Pkg         194ms ± 5%        180ms ± 4%   -7.06%  (p=0.016 n=5+5)

name  old alloc/op      new alloc/op      delta
Pkg        36.2MB ± 0%       34.7MB ± 0%   -4.09%  (p=0.008 n=5+5)

name  old allocs/op     new allocs/op     delta
Pkg          191k ± 1%         179k ± 0%   -6.43%  (p=0.008 n=5+5)

name  old object-bytes  new object-bytes  delta
Pkg          462k ± 0%         415k ± 0%  -10.18%  (p=0.008 n=5+5)

name  old export-bytes  new export-bytes  delta
Pkg          51.0 ± 0%         51.0 ± 0%     ~     (all equal)


Change-Id: I6e04f52b41fd77a2181466160795f35d13b491b4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment