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

Issue 7504044: code review 7504044: runtime: faster hashmap implementation. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 1 month ago by khr
Modified:
11 years, 1 month ago
Reviewers:
minux1, taj, khr1
CC:
golang-dev
Visibility:
Public.

Description

runtime: faster hashmap implementation. Hashtable is arranged as an array of 8-entry buckets with chained overflow. Each bucket has 8 extra hash bits per key to provide quick lookup within a bucket. Table is grown incrementally. Update issue 3885 Go time drops from 0.51s to 0.34s.

Patch Set 1 #

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

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

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

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

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

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

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

Total comments: 11

Patch Set 9 : diff -r f9e10e016342 https://code.google.com/p/go/ #

Total comments: 4

Patch Set 10 : diff -r f9e10e016342 https://code.google.com/p/go/ #

Total comments: 1

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

Patch Set 12 : diff -r 61fa5c7d741f https://code.google.com/p/go/ #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+1500 lines, -1184 lines) Patch
M src/cmd/gc/builtin.c View 1 2 3 4 5 6 7 8 9 1 chunk +6 lines, -0 lines 0 comments Download
M src/cmd/gc/range.c View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M src/cmd/gc/walk.c View 1 2 3 4 5 6 7 8 9 10 2 chunks +69 lines, -3 lines 0 comments Download
M src/cmd/ld/dwarf.c View 1 2 3 4 5 6 7 8 9 10 34 chunks +39 lines, -220 lines 0 comments Download
M src/pkg/runtime/hashmap.h View 1 2 3 4 5 6 7 8 9 1 chunk +14 lines, -166 lines 0 comments Download
M src/pkg/runtime/hashmap.c View 1 2 3 4 5 6 7 8 9 10 22 chunks +882 lines, -789 lines 1 comment Download
A src/pkg/runtime/hashmap_fast.c View 1 2 3 4 5 6 7 8 9 10 1 chunk +149 lines, -0 lines 0 comments Download
A src/pkg/runtime/map_test.go View 1 2 3 4 5 6 7 8 9 10 1 chunk +282 lines, -0 lines 0 comments Download
M src/pkg/runtime/mapspeed_test.go View 1 2 3 4 5 6 7 8 9 2 chunks +54 lines, -0 lines 0 comments Download
M src/pkg/runtime/runtime.h View 1 2 3 4 5 2 chunks +1 line, -2 lines 0 comments Download
M src/pkg/runtime/runtime.c View 1 2 3 4 5 1 chunk +2 lines, -2 lines 0 comments Download

Messages

Total messages: 43
khr
Hello r@golang.org, rsc@golang.org, m3b@google.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
11 years, 1 month ago (2013-03-18 23:37:02 UTC) #1
dave_cheney.net
Wonderful. Can you please add some benchmark data to the issue description.
11 years, 1 month ago (2013-03-18 23:39:27 UTC) #2
bradfitz
hasmap_fast looks like C, but isn't named *.c. Is it built? or leftover debugging? On ...
11 years, 1 month ago (2013-03-18 23:45:45 UTC) #3
bradfitz
https://codereview.appspot.com/7504044/diff/13012/src/cmd/gc/walk.c File src/cmd/gc/walk.c (right): https://codereview.appspot.com/7504044/diff/13012/src/cmd/gc/walk.c#newcode1022 src/cmd/gc/walk.c:1022: (widthptr == 8 && (t->down->etype == TINT || t->down->etype ...
11 years, 1 month ago (2013-03-18 23:48:52 UTC) #4
khr1
It is #included multiple times from hashmap.c using different macro settings. I'd like to name ...
11 years, 1 month ago (2013-03-18 23:49:34 UTC) #5
bradfitz
Did you try // +build ignore near the top of the file? On Mon, Mar ...
11 years, 1 month ago (2013-03-18 23:52:02 UTC) #6
r
a small start. https://codereview.appspot.com/7504044/diff/13012/src/pkg/runtime/hashmap_fast File src/pkg/runtime/hashmap_fast (right): https://codereview.appspot.com/7504044/diff/13012/src/pkg/runtime/hashmap_fast#newcode1 src/pkg/runtime/hashmap_fast:1: // Copyright 2013 The Go Authors. ...
11 years, 1 month ago (2013-03-18 23:55:03 UTC) #7
khr1
I think it is only explicit uintptr. There are separate TPTR32 and TPTR64 etypes. Maybe ...
11 years, 1 month ago (2013-03-18 23:56:00 UTC) #8
khr1
Ah, secret sauce. Fixed. On Mon, Mar 18, 2013 at 4:52 PM, Brad Fitzpatrick <bradfitz@golang.org>wrote: ...
11 years, 1 month ago (2013-03-18 23:56:30 UTC) #9
bradfitz
I wrote up some quick benchmarks, but at least the random ones I picked don't ...
11 years, 1 month ago (2013-03-19 00:12:40 UTC) #10
khr1
You're triggering mapaccess2, I've only optimized mapaccess1. Try "_ = m[x]" instead of "_, _ ...
11 years, 1 month ago (2013-03-19 00:29:22 UTC) #11
bradfitz
On Mon, Mar 18, 2013 at 5:29 PM, Keith Randall <khr@google.com> wrote: > You're triggering ...
11 years, 1 month ago (2013-03-19 00:35:15 UTC) #12
bradfitz
On Mon, Mar 18, 2013 at 5:35 PM, Brad Fitzpatrick <bradfitz@golang.org>wrote: > On Mon, Mar ...
11 years, 1 month ago (2013-03-19 18:41:04 UTC) #13
rsc
I have not read the C code yet. https://codereview.appspot.com/7504044/diff/23001/src/cmd/gc/walk.c File src/cmd/gc/walk.c (right): https://codereview.appspot.com/7504044/diff/23001/src/cmd/gc/walk.c#newcode1015 src/cmd/gc/walk.c:1015: } ...
11 years, 1 month ago (2013-03-19 18:59:17 UTC) #14
rsc
LGTM I read a printout. It looks good. Some general notes that apply throughout. I'm ...
11 years, 1 month ago (2013-03-19 20:46:38 UTC) #15
khr1
On Mon, Mar 18, 2013 at 4:55 PM, <r@golang.org> wrote: > a small start. > ...
11 years, 1 month ago (2013-03-20 00:06:20 UTC) #16
khr1
I've added an empty map check, plus a check to not call hash for a ...
11 years, 1 month ago (2013-03-20 00:06:25 UTC) #17
khr1
On Tue, Mar 19, 2013 at 11:59 AM, <rsc@golang.org> wrote: > I have not read ...
11 years, 1 month ago (2013-03-20 00:06:29 UTC) #18
khr1
On Tue, Mar 19, 2013 at 1:46 PM, <rsc@golang.org> wrote: > LGTM > > I ...
11 years, 1 month ago (2013-03-20 00:06:36 UTC) #19
bradfitz
On Tue, Mar 19, 2013 at 5:06 PM, Keith Randall <khr@google.com> wrote: > I've added ...
11 years, 1 month ago (2013-03-20 15:40:59 UTC) #20
rsc
LGTM https://codereview.appspot.com/7504044/diff/36001/src/cmd/gc/walk.c File src/cmd/gc/walk.c (right): https://codereview.appspot.com/7504044/diff/36001/src/cmd/gc/walk.c#newcode678 src/cmd/gc/walk.c:678: } else { drop else {, unindent block. ...
11 years, 1 month ago (2013-03-20 16:07:31 UTC) #21
ugorji
On 2013/03/18 23:37:02, khr wrote: > Hello mailto:r@golang.org, mailto:rsc@golang.org, mailto:m3b@google.com (cc: > mailto:golang-dev@googlegroups.com), > > ...
11 years, 1 month ago (2013-03-20 17:50:51 UTC) #22
remyoudompheng
Can't you use a (256)T array to map 1-byte integers to things? It seems more ...
11 years, 1 month ago (2013-03-20 17:53:08 UTC) #23
ugorji
The thing is that only a few bytes may be mapped. Currently, I do a ...
11 years, 1 month ago (2013-03-20 18:03:55 UTC) #24
bradfitz
On Wed, Mar 20, 2013 at 10:53 AM, Rémy Oudompheng <remyoudompheng@gmail.com>wrote: > Can't you use ...
11 years, 1 month ago (2013-03-20 18:07:25 UTC) #25
rsc
I don't believe it is worth the bloat for 1 and 2 byte keys, at ...
11 years, 1 month ago (2013-03-20 18:10:52 UTC) #26
bradfitz
Bit of a catch-22. People won't use map[byte]T if it's slow, and we won't make ...
11 years, 1 month ago (2013-03-20 18:12:35 UTC) #27
r
That seems a fine situation to me. -rob On Mar 20, 2013 11:12 AM, "Brad ...
11 years, 1 month ago (2013-03-20 18:17:26 UTC) #28
bradfitz
We could all just use C. It's a bit more of a pain in the ...
11 years, 1 month ago (2013-03-20 18:19:19 UTC) #29
rsc
On Wed, Mar 20, 2013 at 2:07 PM, Brad Fitzpatrick <bradfitz@golang.org>wrote: > That was my ...
11 years, 1 month ago (2013-03-20 18:20:39 UTC) #30
ugorji
I'm with Brad here. Looking at the code, it's about 120 lines each for 2 ...
11 years, 1 month ago (2013-03-20 18:29:31 UTC) #31
rsc
Let's start with just 4 and 8 please. Russ
11 years, 1 month ago (2013-03-20 18:46:44 UTC) #32
khr1
Here's some speed and size graphs. The speed graphs are for lookups. On Wed, Mar ...
11 years, 1 month ago (2013-03-20 20:23:33 UTC) #33
khr1
On Wed, Mar 20, 2013 at 10:50 AM, <ugorji@gmail.com> wrote: > On 2013/03/18 23:37:02, khr ...
11 years, 1 month ago (2013-03-20 20:48:27 UTC) #34
rsc
LGTM
11 years, 1 month ago (2013-03-20 20:50:20 UTC) #35
khr
*** Submitted as https://code.google.com/p/go/source/detail?r=0fce55d10d18 *** runtime: faster hashmap implementation. Hashtable is arranged as an array ...
11 years, 1 month ago (2013-03-20 20:51:34 UTC) #36
taj
https://codereview.appspot.com/7504044/diff/59001/src/pkg/runtime/hashmap.c File src/pkg/runtime/hashmap.c (right): https://codereview.appspot.com/7504044/diff/59001/src/pkg/runtime/hashmap.c#newcode225 src/pkg/runtime/hashmap.c:225: if(valuesize >= MAXVALUESIZE) { should this be ">" instead ...
11 years, 1 month ago (2013-03-21 19:04:25 UTC) #37
minux1
cmd/ld/dwarf.c reverted Russ' last DWARFv2 change, why?
11 years, 1 month ago (2013-03-21 19:35:32 UTC) #38
minux1
runtime-gdb.py is broken after this change, please see https://code.google.com/p/go/issues/detail?id=5098.
11 years, 1 month ago (2013-03-21 19:51:23 UTC) #39
khr1
Whoops, that was not intentional. Something sync'd strangely. I will fix. On Thu, Mar 21, ...
11 years, 1 month ago (2013-03-21 20:26:06 UTC) #40
khr1
Yes, the internal format of maps has changed. I will work on the appropriate change ...
11 years, 1 month ago (2013-03-21 20:27:26 UTC) #41
minux1
On Fri, Mar 22, 2013 at 4:27 AM, Keith Randall <khr@google.com> wrote: > Yes, the ...
11 years, 1 month ago (2013-03-21 20:30:11 UTC) #42
khr1
11 years, 1 month ago (2013-03-21 20:51:14 UTC) #43
Ah, I see you fixed it already.

https://code.google.com/p/go/source/detail?r=decec27a013432a3c00bb4928ce2316b...


On Thu, Mar 21, 2013 at 1:26 PM, Keith Randall <khr@google.com> wrote:

> Whoops, that was not intentional.  Something sync'd strangely.  I will fix.
>
>
> On Thu, Mar 21, 2013 at 12:35 PM, <minux.ma@gmail.com> wrote:
>
>> cmd/ld/dwarf.c reverted Russ' last DWARFv2 change, why?
>>
>>
https://codereview.appspot.**com/7504044/<https://codereview.appspot.com/7504...
>>
>
>
Sign in to reply to this message.

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