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

Issue 12128044: code review 12128044: runtime: optimize some hash lookups. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 7 months ago by khr
Modified:
11 years, 7 months ago
Reviewers:
rsc, bradfitz
CC:
golang-dev, bradfitz, khr1, rsc
Visibility:
Public.

Description

runtime: optimize some hash lookups. When comparing strings, check these (in order): - length mismatch => not equal - string pointer equal => equal - if length is short: - memeq on body - if length is long: - compare first&last few bytes, if different => not equal - save entry as a possible match - after checking every entry, if there is only one possible match, use memeq on that entry. Otherwise, fallback to hash. benchmark old ns/op new ns/op delta BenchmarkSameLengthMap 43 4 -89.77% Fixes issue 5194. Update issue 3885.

Patch Set 1 #

Patch Set 2 : diff -r 521dd78cd28e https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 3 : diff -r 521dd78cd28e https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 4 : diff -r 2f6ebc31b696 https://khr%40golang.org@code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+128 lines, -63 lines) Patch
M src/pkg/runtime/hashmap.c View 1 1 chunk +37 lines, -20 lines 0 comments Download
M src/pkg/runtime/hashmap_fast.c View 1 6 chunks +77 lines, -43 lines 0 comments Download
M src/pkg/runtime/mapspeed_test.go View 1 1 chunk +14 lines, -0 lines 0 comments Download

Messages

Total messages: 5
khr
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://khr%40golang.org@code.google.com/p/go/
11 years, 7 months ago (2013-07-30 23:11:46 UTC) #1
bradfitz
LGTM Did any of the other benchmark numbers change?
11 years, 7 months ago (2013-07-30 23:45:02 UTC) #2
khr1
Everything else was in the noise. On Tue, Jul 30, 2013 at 4:45 PM, <bradfitz@golang.org> ...
11 years, 7 months ago (2013-07-30 23:47:42 UTC) #3
rsc
LGTM
11 years, 7 months ago (2013-07-31 00:22:19 UTC) #4
khr
11 years, 7 months ago (2013-07-31 04:40:00 UTC) #5
*** Submitted as https://code.google.com/p/go/source/detail?r=2faab4336bf1 ***

runtime: optimize some hash lookups.

When comparing strings, check these (in order):
- length mismatch => not equal
- string pointer equal => equal
- if length is short:
  - memeq on body
- if length is long:
  - compare first&last few bytes, if different => not equal
  - save entry as a possible match
  - after checking every entry, if there is only one possible
    match, use memeq on that entry.  Otherwise, fallback to hash.

benchmark                 old ns/op    new ns/op    delta
BenchmarkSameLengthMap           43            4  -89.77%

Fixes issue 5194.
Update issue 3885.

R=golang-dev, bradfitz, khr, rsc
CC=golang-dev
https://codereview.appspot.com/12128044
Sign in to reply to this message.

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