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

Issue 6823043: code review 6823043: image/jpeg: change block from [64]int to [64]int32. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 9 months ago by nigeltao
Modified:
12 years, 9 months ago
Reviewers:
CC:
r, golang-dev, rsc
Visibility:
Public.

Description

image/jpeg: change block from [64]int to [64]int32. On 6g/linux: benchmark old ns/op new ns/op delta BenchmarkFDCT 4606 4241 -7.92% BenchmarkIDCT 4187 3923 -6.31% BenchmarkDecodeBaseline 3154864 3170224 +0.49% BenchmarkDecodeProgressive 4072812 4017132 -1.37% BenchmarkEncode 39406920 34596760 -12.21% Stack requirements before (from 'go tool 6g -S'): (scan.go:37) TEXT (*decoder).processSOS+0(SB),$1352-32 (writer.go:448) TEXT (*encoder).writeSOS+0(SB),$5344-24 after: (scan.go:37) TEXT (*decoder).processSOS+0(SB),$1064-32 (writer.go:448) TEXT (*encoder).writeSOS+0(SB),$2520-24 Also, in encoder.writeSOS, re-use the yBlock scratch buffer for Cb and Cr. This reduces the stack requirement slightly, but also avoids an unlucky coincidence where a BenchmarkEncode stack split lands between encoder.writeByte and bufio.Writer.WriteByte, which occurs very often during Huffman encoding and is otherwise disasterous for the final benchmark number. FWIW, the yBlock re-use *without* the s/int/int32/ change does not have a noticable effect on the benchmarks.

Patch Set 1 #

Patch Set 2 : diff -r 8e87cb8dca7d https://code.google.com/p/go #

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

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+46 lines, -48 lines) Patch
M src/pkg/image/jpeg/dct_test.go View 1 3 chunks +5 lines, -5 lines 0 comments Download
M src/pkg/image/jpeg/huffman.go View 1 1 chunk +3 lines, -3 lines 0 comments Download
M src/pkg/image/jpeg/idct.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/image/jpeg/reader.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/image/jpeg/scan.go View 1 8 chunks +12 lines, -12 lines 0 comments Download
M src/pkg/image/jpeg/writer.go View 1 2 3 8 chunks +24 lines, -26 lines 0 comments Download

Messages

Total messages: 3
nigeltao
Hello r@golang.org (cc: golang-dev@googlegroups.com, rsc@golang.org), I'd like you to review this change to https://code.google.com/p/go
12 years, 9 months ago (2012-10-29 05:22:15 UTC) #1
r
LGTM
12 years, 9 months ago (2012-10-29 14:42:50 UTC) #2
nigeltao
12 years, 9 months ago (2012-10-30 00:11:08 UTC) #3
*** Submitted as http://code.google.com/p/go/source/detail?r=959dee37d03d ***

image/jpeg: change block from [64]int to [64]int32.

On 6g/linux:
benchmark                     old ns/op    new ns/op    delta
BenchmarkFDCT                      4606         4241   -7.92%
BenchmarkIDCT                      4187         3923   -6.31%
BenchmarkDecodeBaseline         3154864      3170224   +0.49%
BenchmarkDecodeProgressive      4072812      4017132   -1.37%
BenchmarkEncode                39406920     34596760  -12.21%

Stack requirements before (from 'go tool 6g -S'):
(scan.go:37) TEXT    (*decoder).processSOS+0(SB),$1352-32
(writer.go:448) TEXT    (*encoder).writeSOS+0(SB),$5344-24

after:
(scan.go:37) TEXT    (*decoder).processSOS+0(SB),$1064-32
(writer.go:448) TEXT    (*encoder).writeSOS+0(SB),$2520-24

Also, in encoder.writeSOS, re-use the yBlock scratch buffer for Cb and
Cr. This reduces the stack requirement slightly, but also avoids an
unlucky coincidence where a BenchmarkEncode stack split lands between
encoder.writeByte and bufio.Writer.WriteByte, which occurs very often
during Huffman encoding and is otherwise disasterous for the final
benchmark number. FWIW, the yBlock re-use *without* the s/int/int32/
change does not have a noticable effect on the benchmarks.

R=r
CC=golang-dev, rsc
http://codereview.appspot.com/6823043
Sign in to reply to this message.

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