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

Issue 4441073: code review 4441073: adler32: speed up ~40% by avoiding bounds checks (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years ago by bradfitz
Modified:
13 years ago
Reviewers:
CC:
rsc, bradfitzgoog, eds, golang-dev
Visibility:
Public.

Description

adler32: speed up ~40% by avoiding bounds checks before & after: adler32.BenchmarkGolden 100000 14747 ns/op adler32.BenchmarkGolden 200000 8761 ns/op Found by profiling PNG encoding.

Patch Set 1 #

Patch Set 2 : diff -r 4f0fd7d49dfa https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 3 : diff -r 4f0fd7d49dfa https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r 982b40af24fb https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+16 lines, -2 lines) Patch
M src/pkg/hash/adler32/adler32.go View 1 1 chunk +2 lines, -2 lines 0 comments Download
M src/pkg/hash/adler32/adler32_test.go View 1 2 2 chunks +14 lines, -0 lines 0 comments Download

Messages

Total messages: 9
bradfitz
Hello rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
13 years ago (2011-04-28 04:20:38 UTC) #1
rsc
Please change the benchmark. io.WriteString contains an allocation (string -> []byte) so the benchmark is ...
13 years ago (2011-04-28 04:23:19 UTC) #2
bradfitz
Hello rsc (cc: golang-dev@googlegroups.com), Please take another look.
13 years ago (2011-04-28 04:29:36 UTC) #3
bradfitzgoog
Whoops. Was just blindly copying the existing tests as my benchmark. Didn't notice the allocation. ...
13 years ago (2011-04-28 04:30:10 UTC) #4
eds
http://codereview.appspot.com/4441073/diff/2001/src/pkg/hash/adler32/adler32.go File src/pkg/hash/adler32/adler32.go (right): http://codereview.appspot.com/4441073/diff/2001/src/pkg/hash/adler32/adler32.go#newcode46 src/pkg/hash/adler32/adler32.go:46: for _, pi := range p { Other ideas ...
13 years ago (2011-04-28 04:30:36 UTC) #5
bradfitz
Evan, I'll leave those for you. :-) This satisfies my current itch and I'm working ...
13 years ago (2011-04-28 04:32:23 UTC) #6
rsc
LGTM
13 years ago (2011-04-28 04:34:51 UTC) #7
bradfitz
*** Submitted as http://code.google.com/p/go/source/detail?r=ff32eff02b8e *** adler32: speed up ~40% by avoiding bounds checks before & ...
13 years ago (2011-04-28 04:36:14 UTC) #8
eds
13 years ago (2011-04-28 07:25:33 UTC) #9
On Thu, Apr 28, 2011 at 4:32 PM, Brad Fitzpatrick <bradfitz@golang.org> wrote:
> Evan, I'll leave those for you.  :-)

In case anyone's curious, neither suggestion ended up making much
difference. Taking the branch out of the loop helped a little bit in
the worst case, but was actually a little worse in the current code's
best case. On average it was a slight win, but hardly worth it.

The uintptr change was just all around worse.

- Evan
Sign in to reply to this message.

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