Skip to content
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

add parallel benchmark #6

Merged
merged 1 commit into from
May 9, 2019
Merged

add parallel benchmark #6

merged 1 commit into from
May 9, 2019

Conversation

rogpeppe
Copy link
Owner

@rogpeppe rogpeppe commented May 9, 2019

When many UUIDs are being generated concurrently,
contention on the atomic counter can slow things down.

There might be ways to speed this up, but for now, just
add a parallel benchmark so we can measure the baseline.

Initial results with go test -bench . -cpu 1,2 on my machine (two physical cores):

BenchmarkContended     	56413502	        18.3 ns/op
BenchmarkContended-2   	82533951	        33.5 ns/op

Note that the 33.5ns/op measure is worse than it appears, because
that's wall ns/op, not cpu-ns/op (see golang/go#31884), so the time is actually 67.0ns/op when contended.

When many UUIDs are being generated concurrently,
contention on the atomic counter can slow things down.

There might be ways to speed this up, but for now, just
add a parallel benchmark so we can measure the baseline.

Initial results with `go test -bench  . -cpu 1,2` on my machine (two physical cores):

	BenchmarkContended     	56413502	        18.3 ns/op
	BenchmarkContended-2   	82533951	        33.5 ns/op

Note that the 33.5ns/op measure is worse than it appears, because
that's wall ns/op, not cpu-ns/op (see golang/go#31884), so the time is actually 67.0ns/op when contended.
@rogpeppe rogpeppe merged commit a295de8 into master May 9, 2019
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.

None yet

1 participant