Skip to content

finished first pass on i3-8100B #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

finished first pass on i3-8100B #3

wants to merge 3 commits into from

Conversation

andrewzheng8
Copy link
Collaborator

Andrews-Mini:metrics andrewzheng$ go test -bench=.
goos: darwin
goarch: amd64
pkg: bradfieldcs/csi/systems/mem-hier-2
cpu: Intel(R) Core(TM) i3-8100B CPU @ 3.60GHz
BenchmarkMetrics/Average_age-4 43518 28287 ns/op
BenchmarkMetrics/Average_payment-4 5706 200055 ns/op
BenchmarkMetrics/Payment_stddev-4 2706 423003 ns/op
PASS
ok bradfieldcs/csi/systems/mem-hier-2 5.895s

Considering further unrolling of standard deviation to take advantage of long latency in float division.

@andrewzheng8
Copy link
Collaborator Author

andrewzheng8 commented Apr 13, 2021

M1 numbers on MBP
go test -bench=.
goos: darwin
goarch: arm64
pkg: bradfieldcs/csi/systems/mem-hier-2
BenchmarkMetrics/Average_age-8 72829 17640 ns/op
BenchmarkMetrics/Average_payment-8 10000 118798 ns/op
BenchmarkMetrics/Payment_stddev-8 4498 259572 ns/op
PASS
ok bradfieldcs/csi/systems/mem-hier-2 5.092s

M1 runs twice as fast as old i3 chip. Mainly because of larger cache?

for acc := range accChan {
accSum += acc
count += 1
if count == 4 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gobyexample.com/range-over-channels fwiw I was doing this break too but then I saw you can close a channel and ranging over a closed channel stops once it's empty

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. I knew you could could stop when closed, but I didn't think about closing the channel being currently looped over. Thanks!

Before I had a separate go routine wait and close the channel, but I think I set it up wrong and it ended up with some race conditions.

accChan <- (acc0 + acc1) + (acc2 + acc3)
}

func procAccPayStdDev (i, stop int, payments PaymentsSlice, accChan chan<- float64) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 🔥 , was a fun read

@andrewzheng8
Copy link
Collaborator Author

update std dev to calc in one pass:

Andrews-Mini:metrics andrewzheng$ go test -bench=.
goos: darwin
goarch: amd64
pkg: bradfieldcs/csi/systems/mem-hier-2
cpu: Intel(R) Core(TM) i3-8100B CPU @ 3.60GHz
BenchmarkMetrics/Average_age-4 41005 28130 ns/op
BenchmarkMetrics/Average_payment-4 5968 189153 ns/op
BenchmarkMetrics/Payment_stddev-4 4702 257488 ns/op
PASS
ok bradfieldcs/csi/systems/mem-hier-2 5.914s

@andrewzheng8
Copy link
Collaborator Author

new M1 benchmark:

goos: darwin
goarch: arm64
pkg: bradfieldcs/csi/systems/mem-hier-2
BenchmarkMetrics/Average_age-8 65340 17490 ns/op
BenchmarkMetrics/Average_payment-8 9471 116963 ns/op
BenchmarkMetrics/Payment_stddev-8 9590 154087 ns/op
PASS
ok bradfieldcs/csi/systems/mem-hier-2 5.251s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants