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

attempt to allocate less by using shared buffers #18

Merged
merged 5 commits into from
May 4, 2020

Conversation

whyrusleeping
Copy link
Owner

Working on reusing buffers to avoid more allocations

@whyrusleeping
Copy link
Owner Author

goos: linux
goarch: amd64
pkg: github.com/whyrusleeping/cbor-gen/testing
BenchmarkMarshaling-12    	  397550	      3061 ns/op	    1248 B/op	      62 allocs/op
PASS
ok  	github.com/whyrusleeping/cbor-gen/testing	2.190s
why@whynix ~/c/cbor-gen (feat/some-shared-buffers)> go test ./testing -bench=.
goos: linux
goarch: amd64
pkg: github.com/whyrusleeping/cbor-gen/testing
BenchmarkMarshaling-12    	  877396	      1226 ns/op	     240 B/op	      15 allocs/op
PASS
ok  	github.com/whyrusleeping/cbor-gen/testing	2.024s

@whyrusleeping whyrusleeping requested review from magik6k and Kubuxu May 3, 2020 19:17
@whyrusleeping whyrusleeping force-pushed the feat/some-shared-buffers branch from f946256 to 2d9e79a Compare May 3, 2020 19:17
@whyrusleeping whyrusleeping marked this pull request as ready for review May 4, 2020 19:22
return err
}
{{ if .NeedsScratch }}
scratch := make([]byte, 9)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some comment on why 9 would be nice (my guess is 1b for header + 8b to be able to fit up to int64)

Copy link
Collaborator

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

This looks faster

@whyrusleeping whyrusleeping merged commit 6496743 into master May 4, 2020
@whyrusleeping whyrusleeping deleted the feat/some-shared-buffers branch May 4, 2020 20:42
@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 tasks
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