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

Issue 7314095: code review 7314095: strings: better mean complexity for Count and Index. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 4 months ago by remyoudompheng
Modified:
12 years, 4 months ago
Reviewers:
CC:
rsc, donovanhide_gmail.com, remyoudompheng, golang-dev
Visibility:
Public.

Description

strings: better mean complexity for Count and Index. The O(n+m) complexity is obtained probabilistically by using Rabin-Karp algorithm, which provides the needed complexity unless exceptional collisions occur, without memory allocation. benchmark old ns/op new ns/op delta BenchmarkIndexHard1 6532331 4045886 -38.06% BenchmarkIndexHard2 8178173 4038975 -50.61% BenchmarkIndexHard3 6973687 4042591 -42.03% BenchmarkCountHard1 6270864 4071090 -35.08% BenchmarkCountHard2 7838039 4072853 -48.04% BenchmarkCountHard3 6697828 4071964 -39.20% BenchmarkIndexTorture 2730546 28934 -98.94% BenchmarkCountTorture 2729622 29064 -98.94% Fixes issue 4600.

Patch Set 1 #

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

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

Total comments: 14

Patch Set 4 : diff -r 3836bcbafa69 https://go.googlecode.com/hg/ #

Total comments: 2

Patch Set 5 : diff -r 0adf91947752 https://go.googlecode.com/hg/ #

Patch Set 6 : diff -r 0adf91947752 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+109 lines, -8 lines) Patch
M src/pkg/strings/strings.go View 1 2 3 4 3 chunks +58 lines, -8 lines 0 comments Download
M src/pkg/strings/strings_test.go View 1 1 chunk +51 lines, -0 lines 0 comments Download

Messages

Total messages: 11
remyoudompheng
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
12 years, 4 months ago (2013-02-14 00:01:22 UTC) #1
remyoudompheng
I would be interested in benchmark comparisons with, for example, KMP-like algorithms which I think ...
12 years, 4 months ago (2013-02-14 00:02:33 UTC) #2
rsc
Regardless of how it compares to KMP, I think this is worth doing. https://codereview.appspot.com/7314095/diff/5001/src/pkg/strings/strings.go File ...
12 years, 4 months ago (2013-02-14 02:44:07 UTC) #3
nigeltao
https://codereview.appspot.com/7314095/diff/5001/src/pkg/strings/strings.go File src/pkg/strings/strings.go (right): https://codereview.appspot.com/7314095/diff/5001/src/pkg/strings/strings.go#newcode59 src/pkg/strings/strings.go:59: const Prime = 16777619 On 2013/02/14 02:44:07, rsc wrote: ...
12 years, 4 months ago (2013-02-14 08:13:59 UTC) #4
remyoudompheng
Hello rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 4 months ago (2013-02-16 09:48:56 UTC) #5
remyoudompheng
Somehow it was slowed down a bit by the changes: new benchcmp results benchmark old ...
12 years, 4 months ago (2013-02-16 09:49:35 UTC) #6
rsc
LGTM Very nice.
12 years, 4 months ago (2013-02-16 13:43:36 UTC) #7
Donovan
Some possible to changes to improve performance on the Count function. Was intrigued to see ...
12 years, 4 months ago (2013-02-16 16:19:14 UTC) #8
remyoudompheng
Hello rsc@golang.org, donovanhide@gmail.com, remyoudompheng@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
12 years, 4 months ago (2013-02-17 12:00:19 UTC) #9
remyoudompheng
Now: benchmark old ns/op new ns/op delta BenchmarkIndexHard1 6532331 4045886 -38.06% BenchmarkIndexHard2 8178173 4038975 -50.61% ...
12 years, 4 months ago (2013-02-17 12:05:59 UTC) #10
remyoudompheng
12 years, 4 months ago (2013-02-17 12:21:13 UTC) #11
*** Submitted as https://code.google.com/p/go/source/detail?r=6f23480a76e1 ***

strings: better mean complexity for Count and Index.

The O(n+m) complexity is obtained probabilistically
by using Rabin-Karp algorithm, which provides the needed complexity
unless exceptional collisions occur, without memory allocation.

benchmark                 old ns/op    new ns/op    delta
BenchmarkIndexHard1         6532331      4045886  -38.06%
BenchmarkIndexHard2         8178173      4038975  -50.61%
BenchmarkIndexHard3         6973687      4042591  -42.03%
BenchmarkCountHard1         6270864      4071090  -35.08%
BenchmarkCountHard2         7838039      4072853  -48.04%
BenchmarkCountHard3         6697828      4071964  -39.20%
BenchmarkIndexTorture       2730546        28934  -98.94%
BenchmarkCountTorture       2729622        29064  -98.94%

Fixes issue 4600.

R=rsc, donovanhide, remyoudompheng
CC=golang-dev
https://codereview.appspot.com/7314095
Sign in to reply to this message.

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