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

Issue 6248049: code review 6248049: cmd/6g, cmd/8g: move panicindex calls out of line (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 8 months ago by rsc
Modified:
12 years, 7 months ago
Reviewers:
mtj1
CC:
golang-dev, gri, r, dave_cheney.net
Visibility:
Public.

Description

cmd/6g, cmd/8g: move panicindex calls out of line The old code generated for a bounds check was CMP JLT ok CALL panicindex ok: ... The new code is (once the linker finishes with it): CMP JGE panic ... panic: CALL panicindex which moves the calls out of line, putting more useful code in each cache line. This matters especially in tight loops, such as in Fannkuch. The benefit is more modest elsewhere, but real. From test/bench/go1, amd64: benchmark old ns/op new ns/op delta BenchmarkBinaryTree17 6096092000 6088808000 -0.12% BenchmarkFannkuch11 6151404000 4020463000 -34.64% BenchmarkGobDecode 28990050 28894630 -0.33% BenchmarkGobEncode 12406310 12136730 -2.17% BenchmarkGzip 179923 179903 -0.01% BenchmarkGunzip 11219 11130 -0.79% BenchmarkJSONEncode 86429350 86515900 +0.10% BenchmarkJSONDecode 334593800 315728400 -5.64% BenchmarkRevcomp25M 1219763000 1180767000 -3.20% BenchmarkTemplate 492947600 483646800 -1.89% And 386: benchmark old ns/op new ns/op delta BenchmarkBinaryTree17 6354902000 6243000000 -1.76% BenchmarkFannkuch11 8043769000 7326965000 -8.91% BenchmarkGobDecode 19010800 18941230 -0.37% BenchmarkGobEncode 14077500 13792460 -2.02% BenchmarkGzip 194087 193619 -0.24% BenchmarkGunzip 12495 12457 -0.30% BenchmarkJSONEncode 125636400 125451400 -0.15% BenchmarkJSONDecode 696648600 685032800 -1.67% BenchmarkRevcomp25M 2058088000 2052545000 -0.27% BenchmarkTemplate 602140000 589876800 -2.04% To implement this, two new instruction forms: JLT target // same as always JLT $0, target // branch expected not taken JLT $1, target // branch expected taken The linker could also emit the prediction prefixes, but it does not: expected taken branches are reversed so that the expected case is not taken (as in example above), and the default expectaton for such a jump is not taken already.

Patch Set 1 #

Patch Set 2 : diff -r 00a25723a7cd https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r 40632db23c46 https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 771b60b029d4 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1085 lines, -1190 lines) Patch
M src/cmd/6a/a.y View 1 1 chunk +5 lines, -0 lines 0 comments Download
M src/cmd/6a/y.tab.c View 1 2 3 44 chunks +424 lines, -411 lines 0 comments Download
M src/cmd/6g/cgen.c View 1 2 chunks +2 lines, -0 lines 0 comments Download
M src/cmd/6g/gg.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/6g/ggen.c View 1 2 3 4 chunks +5 lines, -0 lines 0 comments Download
M src/cmd/6g/gsubr.c View 1 3 chunks +12 lines, -0 lines 0 comments Download
M src/cmd/6l/optab.c View 1 1 chunk +3 lines, -1 line 0 comments Download
M src/cmd/6l/pass.c View 1 2 3 3 chunks +28 lines, -7 lines 0 comments Download
M src/cmd/8a/a.y View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
M src/cmd/8a/y.tab.h View 1 2 3 4 chunks +19 lines, -25 lines 0 comments Download
M src/cmd/8a/y.tab.c View 1 2 3 88 chunks +547 lines, -739 lines 0 comments Download
M src/cmd/8g/cgen.c View 1 2 2 chunks +2 lines, -0 lines 0 comments Download
M src/cmd/8g/gg.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/cmd/8g/ggen.c View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M src/cmd/8g/gsubr.c View 1 2 1 chunk +7 lines, -0 lines 0 comments Download
M src/cmd/8l/optab.c View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M src/cmd/8l/pass.c View 1 2 1 chunk +19 lines, -6 lines 0 comments Download

Messages

Total messages: 16
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 8 months ago (2012-05-25 06:44:59 UTC) #1
gri
This is great. I've done this in the code gens of V8 and the JVM ...
12 years, 8 months ago (2012-05-25 17:37:11 UTC) #2
r
why not 5g?
12 years, 7 months ago (2012-05-26 17:27:34 UTC) #3
rsc
On Sat, May 26, 2012 at 1:27 PM, <r@golang.org> wrote: > why not 5g? only ...
12 years, 7 months ago (2012-05-28 23:28:43 UTC) #4
dave_cheney.net
> only because i don't know what the right answer is there. > it seems ...
12 years, 7 months ago (2012-05-29 01:23:25 UTC) #5
rsc
*** Submitted as http://code.google.com/p/go/source/detail?r=a1ecb826e0eb *** cmd/6g, cmd/8g: move panicindex calls out of line The old ...
12 years, 7 months ago (2012-05-29 16:09:36 UTC) #6
rsc
This CL also ended up containing an experiment that disables stack splitting in leaf functions. ...
12 years, 7 months ago (2012-05-30 13:32:19 UTC) #7
mtj1
Russ, speaking of x[i] and possible panics, I have a question about bounds checking. In ...
12 years, 7 months ago (2012-05-30 13:43:13 UTC) #8
dave_cheney.net
Did 5g get this side effect? Sent from my iPad On 30/05/2012, at 23:31, Russ ...
12 years, 7 months ago (2012-05-30 13:44:18 UTC) #9
rsc
On Wed, May 30, 2012 at 9:44 AM, Dave Cheney <dave@cheney.net> wrote: > Did 5g ...
12 years, 7 months ago (2012-05-30 14:11:56 UTC) #10
rsc
On Wed, May 30, 2012 at 9:42 AM, Michael Jones <mtj@google.com> wrote: > Dave suggests ...
12 years, 7 months ago (2012-05-30 14:12:57 UTC) #11
mtj1
Metaphorical fruit seems lower the further one is from picking it. ;-) Another question about ...
12 years, 7 months ago (2012-05-30 23:48:59 UTC) #12
rsc
On Wed, May 30, 2012 at 7:48 PM, Michael Jones <mtj@google.com> wrote: > Metaphorical fruit ...
12 years, 7 months ago (2012-05-30 23:57:09 UTC) #13
mtj1
for i := range z.cols { z.cols[i].L = &z.cols[(i+g4-1)%g4] z.cols[i].R = &z.cols[(i+1)%g4] z.cols[i].u = &z.cols[i].node ...
12 years, 7 months ago (2012-05-31 00:00:43 UTC) #14
gri
this is not too bad: for i := range z.cols { c := &z.cols[i] ...
12 years, 7 months ago (2012-05-31 00:10:32 UTC) #15
mtj1
12 years, 7 months ago (2012-05-31 01:17:59 UTC) #16
I'll try that and see if it sits well with me.

Just debugged a subtle problem porting a Sudoku solver from C++ to Go.
Undoing the subclassing using embedding was not hard at all; undoing a
subtle error flowing from the lack of chained assignments (a = b = c)
in Go took two half-days (nights) in the hotel room. ;-)

On Thu, May 31, 2012 at 2:10 AM, Robert Griesemer <gri@golang.org> wrote:
> this is not too bad:
>
> for i := range z.cols {
>    c := &z.cols[i]
>    ...
> }
>
> (that said, sometimes I wished I could get the reference directly, but
> then again, it's not really making a big difference and probably not
> worth the complication)
>
> - gri
>
>
>
>
> On Wed, May 30, 2012 at 5:00 PM, Michael Jones <mtj@google.com> wrote:
>> for i := range z.cols {
>>                z.cols[i].L = &z.cols[(i+g4-1)%g4]
>>                z.cols[i].R = &z.cols[(i+1)%g4]
>>                z.cols[i].u = &z.cols[i].node
>>                z.cols[i].d = &z.cols[i].node
>>                z.cols[i].size = 0
>>                z.cols[i].covered = false
>>        }
>>
>> vs
>>
>> for i,*c := range z.cols {
>>                c.L = &z.cols[(i+g4-1)%g4]
>>                c.R = &z.cols[(i+1)%g4]
>>                c.u = &c.node
>>                c.d = &c.node
>>                c.size = 0
>>                c.covered = false
>>        }
>>
>> On Thu, May 31, 2012 at 1:56 AM, Russ Cox <rsc@golang.org> wrote:
>>> On Wed, May 30, 2012 at 7:48 PM, Michael Jones <mtj@google.com> wrote:
>>>> Metaphorical fruit seems lower the further one is from picking it. ;-)
>>>>
>>>> Another question about Go -- why is range not useful to get addresses?
>>>> Maybe a mark (*) added to the value argument would seem sufficient.
>>>
>>> There are definitely times when I would have used that syntax, but
>>> they've never seemed often enough to invent something.
>>>
>>> Russ
>>
>>
>>
>> --
>> Michael T. Jones | Chief Technology Advocate  | mtj@google.com |  +1
>> 650-335-5765



-- 
Michael T. Jones | Chief Technology Advocate  | mtj@google.com |  +1
650-335-5765
Sign in to reply to this message.

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