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

Issue 5606048: code review 5606048: runtime: add runtime.cputicks() and seed fastrand with it (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 2 months ago by dgryski
Modified:
13 years, 1 month ago
Reviewers:
minux1, dsymonds
CC:
rsc, golang-dev
Visibility:
Public.

Description

runtime: add runtime.cputicks() and seed fastrand with it This patch adds a function to get the current cpu ticks. This is deemed to be 'sufficiently random' to use to seed fastrand to mitigate the algorithmic complexity attacks on the hash table implementation. On AMD64 we use the RDTSC instruction. For 386, this instruction, while valid, is not recognized by 8a so I've inserted the opcode by hand. For ARM, this routine is currently stubbed to return a constant 0 value. Future work: update 8a to recognize RDTSC. Fixes issue 2630.

Patch Set 1 #

Patch Set 2 : diff -r b7e029136522 http://go.googlecode.com/hg/ #

Patch Set 3 : diff -r f79343c8a479 http://go.googlecode.com/hg/ #

Patch Set 4 : diff -r f79343c8a479 http://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 5 : diff -r 1b6e7832103e http://go.googlecode.com/hg/ #

Patch Set 6 : diff -r 1b6e7832103e http://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+28 lines, -1 line) Patch
M src/pkg/runtime/asm_386.s View 1 2 3 1 chunk +9 lines, -0 lines 0 comments Download
M src/pkg/runtime/asm_amd64.s View 1 1 chunk +7 lines, -0 lines 0 comments Download
M src/pkg/runtime/asm_arm.s View 1 1 chunk +10 lines, -0 lines 0 comments Download
M src/pkg/runtime/proc.c View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/runtime/runtime.h View 1 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 14
dgryski
Hello golang-dev@googlegroups.com, I'd like you to review this change to http://go.googlecode.com/hg/
13 years, 2 months ago (2012-02-01 17:29:26 UTC) #1
rsc
This looks fine, but can you use BYTE instructions so that the instruction looks the ...
13 years, 2 months ago (2012-02-01 22:45:31 UTC) #2
dgryski
Hello golang-dev@googlegroups.com, rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 2 months ago (2012-02-02 06:11:17 UTC) #3
dgryski
On 2012/02/01 22:45:31, rsc wrote: > This looks fine, but can you use BYTE instructions ...
13 years, 2 months ago (2012-02-02 06:12:52 UTC) #4
rsc
Looks great; one more tiny change and then I'll submit. Thanks. http://codereview.appspot.com/5606048/diff/7001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): ...
13 years, 2 months ago (2012-02-02 18:53:05 UTC) #5
dgryski
Hello rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 2 months ago (2012-02-02 18:56:20 UTC) #6
dgryski
Hello rsc@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 2 months ago (2012-02-02 19:00:36 UTC) #7
dgryski
On 2012/02/02 19:00:36, dgryski wrote: > Hello mailto:rsc@golang.org (cc: mailto:golang-dev@googlegroups.com), > > Please take another ...
13 years, 2 months ago (2012-02-02 19:02:08 UTC) #8
rsc
LGTM Thanks.
13 years, 2 months ago (2012-02-02 19:08:34 UTC) #9
rsc
*** Submitted as http://code.google.com/p/go/source/detail?r=cd86b08237be *** runtime: add runtime.cputicks() and seed fastrand with it This patch ...
13 years, 2 months ago (2012-02-02 19:09:44 UTC) #10
minux1
But ARM CPUs doesn't have a portable method to get cpu cycles. (the CCNT register ...
13 years, 1 month ago (2012-02-05 22:05:33 UTC) #11
dsymonds
On Mon, Feb 6, 2012 at 9:05 AM, minux <minux.ma@gmail.com> wrote: > Could we change ...
13 years, 1 month ago (2012-02-05 22:14:32 UTC) #12
minux1
On Mon, Feb 6, 2012 at 6:14 AM, David Symonds <dsymonds@golang.org> wrote: > On Mon, ...
13 years, 1 month ago (2012-02-05 22:22:18 UTC) #13
rsc
13 years, 1 month ago (2012-02-05 22:24:01 UTC) #14
It is not a big deal for ARM cputicks to return 0.
Let's leave it at that.  If you want it to return the
current time in nanoseconds, that's fine too.
We don't need to shuffle any of the code that is
calling it.

Russ
Sign in to reply to this message.

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