Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(607)

Issue 15930045: code review 15930045: cmd/gc: use 100x less memory for []byte("string") (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 6 months ago by rsc
Modified:
10 years, 4 months ago
Reviewers:
iant
CC:
golang-codereviews, r, iant, oleku, dave_cheney.net, gobot, bradfitz
Visibility:
Public.

Description

cmd/gc: use 100x less memory for []byte("string") []byte("string") was simplifying to []byte{0: 0x73, 1: 0x74, 2: 0x72, 3: 0x69, 4: 0x6e, 5: 0x67}, but that latter form takes up much more memory in the compiler. Preserve the string form and recognize it to turn global variables initialized this way into linker-initialized data. Reduces the compiler memory footprint for a large []byte initialized this way from approximately 10 kB/B to under 100 B/B. See also issue 6643.

Patch Set 1 #

Patch Set 2 : diff -r 9169cb38c3e8 https://go.googlecode.com/hg #

Patch Set 3 : diff -r 9169cb38c3e8 https://code.google.com/p/go/ #

Patch Set 4 : diff -r 1b7c5daffdff https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+41 lines, -0 lines) Patch
M src/cmd/gc/go.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/gc/obj.c View 1 2 3 1 chunk +28 lines, -0 lines 0 comments Download
M src/cmd/gc/sinit.c View 1 2 chunks +9 lines, -0 lines 0 comments Download
M src/cmd/gc/typecheck.c View 1 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 25
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
10 years, 6 months ago (2013-10-23 03:41:52 UTC) #1
r
Can we do this after 1.2?
10 years, 6 months ago (2013-10-23 04:53:49 UTC) #2
iant
LGTM
10 years, 6 months ago (2013-10-23 14:08:55 UTC) #3
rsc
I'm on the fence about Go 1.2. If you'd rather wait, that's fine.
10 years, 6 months ago (2013-10-23 14:16:13 UTC) #4
r
I would prefer to wait. -rob
10 years, 6 months ago (2013-10-23 14:28:15 UTC) #5
oleku
Is there any particular reason why you would prefer it to wait ? Just curious ...
10 years, 6 months ago (2013-10-23 15:51:35 UTC) #6
rsc
On Wed, Oct 23, 2013 at 11:51 AM, Oleku Konko <oleku.konko@gmail.com> wrote: > Is there ...
10 years, 6 months ago (2013-10-23 15:54:43 UTC) #7
r
There's no point in having a release freeze if we don't freeze the compiler. -rob
10 years, 6 months ago (2013-10-23 16:14:08 UTC) #8
rsc
To be clear, the only reason we'd even consider putting this in Go 1.2 is ...
10 years, 6 months ago (2013-10-23 16:34:49 UTC) #9
oleku
I see your point and appreciate keeping to the rules .... Is there a clear ...
10 years, 6 months ago (2013-10-23 17:19:03 UTC) #10
oleku
Does it have to be 1.3 ??? What about 1.2.1 etc ??? Would the compiler ...
10 years, 6 months ago (2013-10-23 17:20:24 UTC) #11
rsc
On Wed, Oct 23, 2013 at 1:19 PM, Oleku Konko <oleku.konko@gmail.com> wrote: > I see ...
10 years, 6 months ago (2013-10-23 17:20:36 UTC) #12
oleku
Thank you very much ... On Wednesday, October 23, 2013 6:20:34 PM UTC+1, rsc wrote: ...
10 years, 6 months ago (2013-10-24 00:02:22 UTC) #13
dave_cheney.net
Just a note to say I have been using this on my linux/amd64 system without ...
10 years, 5 months ago (2013-11-14 08:14:26 UTC) #14
gobot
R=iant@golang.org (assigned by rsc@golang.org)
10 years, 4 months ago (2013-12-20 01:52:55 UTC) #15
gobot
Replacing golang-dev with golang-codereviews.
10 years, 4 months ago (2013-12-20 02:44:39 UTC) #16
iant
LGTM
10 years, 4 months ago (2013-12-20 16:49:03 UTC) #17
dave_cheney.net
@rsc, would you be able to merge this soon ? On Sat, Dec 21, 2013 ...
10 years, 4 months ago (2013-12-28 04:43:41 UTC) #18
rsc
On Fri, Dec 27, 2013 at 11:43 PM, Dave Cheney <dave@cheney.net> wrote: > @rsc, would ...
10 years, 4 months ago (2014-01-06 20:22:21 UTC) #19
dave_cheney.net
Yes please! Can you freshen the patch so it will clpatch cleanly again. On Tue, ...
10 years, 4 months ago (2014-01-06 20:24:16 UTC) #20
bradfitz
You can just: $ curl https://codereview.appspot.com/download/issue15930045_40001.diff | patch -p1 Only one hunk fails and it's ...
10 years, 4 months ago (2014-01-06 20:25:47 UTC) #21
dave_cheney.net
Hi Russ and Brad, I tried to measure this change today but I think the ...
10 years, 4 months ago (2014-01-07 01:11:35 UTC) #22
dave_cheney.net
I've done some measurements of this CL and I believe it is still useful to ...
10 years, 4 months ago (2014-01-07 01:29:33 UTC) #23
rsc
Thanks!
10 years, 4 months ago (2014-01-07 01:43:44 UTC) #24
rsc
10 years, 4 months ago (2014-01-07 01:43:52 UTC) #25
*** Submitted as https://code.google.com/p/go/source/detail?r=3735f6f1077e ***

cmd/gc: use 100x less memory for []byte("string")

[]byte("string") was simplifying to
[]byte{0: 0x73, 1: 0x74, 2: 0x72, 3: 0x69, 4: 0x6e, 5: 0x67},
but that latter form takes up much more memory in the compiler.
Preserve the string form and recognize it to turn global variables
initialized this way into linker-initialized data.

Reduces the compiler memory footprint for a large []byte initialized
this way from approximately 10 kB/B to under 100 B/B.

See also issue 6643.

R=golang-codereviews, r, iant, oleku.konko, dave, gobot, bradfitz
CC=golang-codereviews
https://codereview.appspot.com/15930045
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b