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

Added Read/WriteExtensionRaw #329

Merged
merged 2 commits into from
Jun 27, 2023
Merged

Conversation

mhr3
Copy link
Contributor

@mhr3 mhr3 commented Jun 27, 2023

Our codebase is using Extensions quite extensively, and we've noticed that reading and writing an Extension with the current msgp API always causes an allocation, which is usually not the case when using any other msgp Read*/Write* methods. Therefore we've added Reader.ReadExtensionRaw() and Writer.WriteExtensionRaw() in this PR which allows zero-alloc code paths for extensions.

goos: darwin
goarch: arm64
pkg: github.com/tinylib/msgp/msgp
BenchmarkExtensionReadWrite/interface-8         	   13196	     89295 ns/op	    8377 B/op	       1 allocs/op
BenchmarkExtensionReadWrite/raw-8               	   13910	     88740 ns/op	    8299 B/op	       0 allocs/op
PASS
ok  	github.com/tinylib/msgp/msgp	4.329s

@philhofer philhofer merged commit 4e26c5d into tinylib:master Jun 27, 2023
@mhr3 mhr3 deleted the raw-extension-methods branch June 28, 2023 09:40
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