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

Issue 102560043: code review 102560043: strings: use Rabin-Karp algorithm for LastIndex (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 6 months ago by ruiu
Modified:
11 years, 3 months ago
Reviewers:
nigeltao, josharian
CC:
golang-codereviews, ality, josharian, bradfitz, dave_cheney.net, nigeltao, gobot, ioe
Visibility:
Public.

Description

strings: use Robin-Karp algorithm for LastIndex benchmark old ns/op new ns/op delta BenchmarkSingleMatch 49443 52275 +5.73% BenchmarkIndex 28.8 27.4 -4.86% BenchmarkLastIndex 14.5 14.0 -3.45% BenchmarkLastIndexHard1 3982782 2309200 -42.02% BenchmarkLastIndexHard2 3985562 2287715 -42.60% BenchmarkLastIndexHard3 3555259 2282866 -35.79%

Patch Set 1 #

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

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

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

Total comments: 2

Patch Set 5 : diff -r 75040398cb4e https://code.google.com/p/go #

Patch Set 6 : diff -r 41a383d40558 https://code.google.com/p/go #

Total comments: 4

Patch Set 7 : diff -r 173175ba9eb71f00f69da09c738523eb4fab36a6 https://code.google.com/p/go #

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+67 lines, -12 lines) Patch
M src/pkg/strings/strings.go View 1 2 3 4 5 6 7 4 chunks +48 lines, -12 lines 0 comments Download
M src/pkg/strings/strings_test.go View 1 2 3 4 5 6 3 chunks +19 lines, -0 lines 0 comments Download

Messages

Total messages: 18
ruiu
Hello golang-codereviews@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go
11 years, 6 months ago (2014-06-20 05:58:01 UTC) #1
ality
s/Robin/Rabin/ in the CL description. Anthony
11 years, 6 months ago (2014-06-20 07:37:49 UTC) #2
josharian
Naive question: Wikipedia says "The Rabin–Karp algorithm is inferior for single pattern searching to Knuth–Morris–Pratt ...
11 years, 5 months ago (2014-06-23 19:30:24 UTC) #3
ruiu
On 2014/06/23 19:30:24, josharian wrote: > Naive question: Wikipedia says "The Rabin–Karp algorithm is inferior ...
11 years, 5 months ago (2014-06-23 20:10:31 UTC) #4
josharian
> However I guess pattern is usually short, so RK is at least not a ...
11 years, 5 months ago (2014-06-23 20:33:14 UTC) #5
ruiu
https://codereview.appspot.com/102560043/diff/60001/src/pkg/strings/strings.go File src/pkg/strings/strings.go (right): https://codereview.appspot.com/102560043/diff/60001/src/pkg/strings/strings.go#newcode214 src/pkg/strings/strings.go:214: h *= primeRK These repetitions are actually different enough ...
11 years, 5 months ago (2014-06-24 04:26:37 UTC) #6
josharian
Donovan's comments in CL 109160044 led me to run the Count benchmarks with this CL: ...
11 years, 5 months ago (2014-06-24 16:34:07 UTC) #7
ruiu
Huh, interesting. What architecture is your CPU?
11 years, 5 months ago (2014-06-24 16:57:02 UTC) #8
josharian
> Huh, interesting. What architecture is your CPU? x86_64. It's a recent retina MBP.
11 years, 5 months ago (2014-06-24 17:18:17 UTC) #9
ruiu
The slowdown was caused by the same reason as CL 109160044 (the last refactoring change ...
11 years, 5 months ago (2014-06-25 06:17:47 UTC) #10
josharian
LGTM but I'd like a fresh set of eyes to also have a look
11 years, 5 months ago (2014-06-26 18:22:56 UTC) #11
dave_cheney.net
Nigel, do you have time to review this ?
11 years, 5 months ago (2014-07-01 00:54:49 UTC) #12
gobot
R=nigeltao@golang.org (assigned by dave@cheney.net)
11 years, 5 months ago (2014-07-01 00:55:18 UTC) #13
josharian
Ping, Nigel.
11 years, 3 months ago (2014-08-29 00:41:17 UTC) #14
ioe
One testing bug and an possible optimization. https://codereview.appspot.com/102560043/diff/100001/src/pkg/strings/strings.go File src/pkg/strings/strings.go (right): https://codereview.appspot.com/102560043/diff/100001/src/pkg/strings/strings.go#newcode195 src/pkg/strings/strings.go:195: case n ...
11 years, 3 months ago (2014-08-29 06:54:40 UTC) #15
ruiu
https://codereview.appspot.com/102560043/diff/100001/src/pkg/strings/strings.go File src/pkg/strings/strings.go (right): https://codereview.appspot.com/102560043/diff/100001/src/pkg/strings/strings.go#newcode195 src/pkg/strings/strings.go:195: case n >= len(s): On 2014/08/29 06:54:40, ioe wrote: ...
11 years, 3 months ago (2014-08-29 18:32:38 UTC) #16
nigeltao
LGTM.
11 years, 3 months ago (2014-09-01 07:43:41 UTC) #17
nigeltao
11 years, 3 months ago (2014-09-01 07:48:30 UTC) #18
*** Submitted as https://code.google.com/p/go/source/detail?r=9e13ce244308 ***

strings: use Rabin-Karp algorithm for LastIndex.

benchmark                  old ns/op     new ns/op     delta
BenchmarkSingleMatch       49443         52275         +5.73%
BenchmarkIndex             28.8          27.4          -4.86%
BenchmarkLastIndex         14.5          14.0          -3.45%
BenchmarkLastIndexHard1    3982782       2309200       -42.02%
BenchmarkLastIndexHard2    3985562       2287715       -42.60%
BenchmarkLastIndexHard3    3555259       2282866       -35.79%

LGTM=josharian, nigeltao
R=golang-codereviews, ality, josharian, bradfitz, dave, nigeltao, gobot,
nightlyone
CC=golang-codereviews
https://codereview.appspot.com/102560043

Committer: Nigel Tao <nigeltao@golang.org>
Sign in to reply to this message.

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