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

Issue 6495114: code review 6495114: bytes, strings: faster Fields

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

Description

bytes, strings: faster Fields I'm unhappy about writing this CL, but Fields is much more common than FieldsFunc and an inherently cheaper operation, because most spaces are ASCII, so it does seem to justify special case code. package bytes: BenchmarkFields 50 23659299 ns/op 44.32 MB/s BenchmarkFieldsFunc 50 42000576 ns/op 24.97 MB/s package strings: BenchmarkFields 100 22852634 ns/op 45.88 MB/s BenchmarkFieldsFunc 50 35050756 ns/op 29.92 MB/s

Patch Set 1 #

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

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

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

Total comments: 9
Unified diffs Side-by-side diffs Delta from patch set Stats (+209 lines, -2 lines) Patch
M src/pkg/bytes/bytes.go View 1 2 3 1 chunk +60 lines, -1 line 2 comments Download
M src/pkg/bytes/bytes_test.go View 1 3 chunks +45 lines, -0 lines 0 comments Download
M src/pkg/strings/strings.go View 1 2 3 1 chunk +60 lines, -1 line 7 comments Download
M src/pkg/strings/strings_test.go View 1 3 chunks +44 lines, -0 lines 0 comments Download

Messages

Total messages: 8
rsc
Hello r (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
13 years, 1 month ago (2012-09-11 03:47:17 UTC) #1
bradfitz
This also makes me sad. I remember smiling at the simplicity of all these functions ...
13 years, 1 month ago (2012-09-11 03:53:40 UTC) #2
rsc
On Mon, Sep 10, 2012 at 11:53 PM, Brad Fitzpatrick <bradfitz@golang.org> wrote: > This also ...
13 years, 1 month ago (2012-09-11 03:55:33 UTC) #3
r
i'm unhappy too, but if you want to make me unhappy make the payoff big ...
13 years, 1 month ago (2012-09-11 05:29:47 UTC) #4
rog
http://codereview.appspot.com/6495114/diff/8001/src/pkg/strings/strings.go File src/pkg/strings/strings.go (right): http://codereview.appspot.com/6495114/diff/8001/src/pkg/strings/strings.go#newcode256 src/pkg/strings/strings.go:256: for i := 0; i < len(s); i++ { ...
13 years, 1 month ago (2012-09-11 10:21:50 UTC) #5
rsc
On Tue, Sep 11, 2012 at 1:29 AM, <r@golang.org> wrote: > i'm unhappy too, but ...
13 years, 1 month ago (2012-09-11 22:18:01 UTC) #6
r
do you have the updated version? http://codereview.appspot.com/6495114/diff/8001/src/pkg/bytes/bytes.go File src/pkg/bytes/bytes.go (right): http://codereview.appspot.com/6495114/diff/8001/src/pkg/bytes/bytes.go#newcode303 src/pkg/bytes/bytes.go:303: if c < ...
13 years, 1 month ago (2012-09-21 09:03:35 UTC) #7
rsc
13 years, 1 month ago (2012-09-21 14:37:59 UTC) #8
On Fri, Sep 21, 2012 at 5:03 AM, <r@golang.org> wrote: > do you have the updated version? No, not yet. I am still thinking about what the right resizing strategy is. I can make the code much faster on the benchmark by estimating the new array size based on fields/byte processed so far, cutting out almost all reallocations, but that gives it the chance to wildly overestimate and overallocate what it would otherwise need. The current code, while slower by being two passes, at least does not overallocate. I'm still not quite sure how to balance those. Probably I will give up that particular speedup and go back to ordinary append. Russ 
Sign in to reply to this message.

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