-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: large string constants being copied unnecessarily #15729
Comments
/cc @randall77 @crawshaw |
Do you see it twice with |
No, I just used
|
This should already be fixed in go 1.7. |
This is still occurring as of tip (4d2ac54). |
Huh. Thanks, reopened. |
I can't reproduce it at tip. (I can with 1.6 though).
|
Definitely still occurring for me (on ebbe4f8). If it makes any difference, I have 818374 Bytes of data; the bug was harder to detect with smaller strings, but it is still identified with |
Well I don't know what the difference is then:
|
I don't know what to suggest; running this on a different machine I get the same result:
|
This is very strange, I don't understand what is going on at all. I don't even understand where the symbol names in your output come from. Maybe @josharian can try on his system? |
@SlyMarbo I just tried this again with tip (82ec4cd). I used your exactly playground code, but I substituted a 65536 byte constant (using I ran: ``bash
Also, the symbols called The fact that you are seeing |
@josharian I'm not sure what's going on. The fact that neither you nor @mwhudson can reproduce definitely suggests I'm doing something wrong, but I'm sure I'm using tip on both machines. Is it possible my tooling has become desynchronised, with |
@josharian Yes, that seems to be what happened; I changed GOROOT to point to tip and it now acts as expected. Sorry for the confusion. |
You don't need to change GOROOT to switch go versions. In fact, the easiest On Sat, 21 May 2016, 20:19 Jamie Hall, notifications@github.com wrote:
|
Yeah, my mistake was to leave my existing Go installation (1.6) as it was, clone tip into a different directory and run I agree that I shouldn't have set GOROOT; it was a hangover from when I was trying to get GoSublime to work nicely. |
As a suggestion you can compile many versions of go into separate go test // uh oh On Sat, 21 May 2016, 21:02 Jamie Hall, notifications@github.com wrote:
|
Great suggestion, thanks @davecheney :) |
go version
)?go/1.6
go env
)?linux/amd64
,darwin/amd64
data
(a few MB of Lorem Ipsum from a web generator).len(data)
bytes.It appears that using a large string constant multiple times within a function results in that constant being copied into the compile binary multiple times. While this may be fine with small strings, it seems unnecessary with large strings and inflates the binary size and compile time significantly.
In the code in which this issue was discovered, the string constant was nearly 30 MB and resulted in the compile time increasing from ~6s to ~13s and the binary from ~27 MB to ~66 MB.
The text was updated successfully, but these errors were encountered: