-
Notifications
You must be signed in to change notification settings - Fork 550
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
Improve json encoding performance for specs-go #343
Improve json encoding performance for specs-go #343
Conversation
This adds basic benchmark tests for the performace of marshaling and unmarshaling the spec into json. These tests are helpful to optimize the performace because the main way the spec is consumed is via json. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
By using ffjson for json encoding we can reduce the time for encoding and decoding. Without: BenchmarkMarsalSpec-4 100000 18276 ns/op BenchmarkUnmarshal-4 30000 55115 ns/op With: BenchmarkMarsalSpec-4 100000 13649 ns/op BenchmarkUnmarshal-4 50000 24747 ns/op This is a reduces time about 25% on marshal and 50% on unmarshal. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
not that i'm disagreeing with it, but I we don't much do any marshaling in the source of this repo presently. Though perhaps it makes sense to be present in the same package? |
@vbatts ya, its for consumers of the package that we provide this. It really helps out alot. i.e. these functions have to be in the same package |
imma use it 😇 i just updated all my tools |
Then ought we put a target in the |
@vbatts updated makefile |
}, | ||
} | ||
|
||
func BenchmarkMarsalSpec(b *testing.B) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo s/Marsal/Marshal/
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
d041388
to
cfec788
Compare
LGTM |
@@ -56,6 +56,11 @@ test: .govet .golint .gitvalidation | |||
.gitvalidation: | |||
git-validation -q -run DCO,short-subject -v -range $(EPOCH_TEST_COMMIT)..HEAD | |||
|
|||
# `go get https://github.com/pquerna/ffjson` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s!https://!!
LGTM beside silly nit |
Improve json encoding performance for specs-go
@crosbymichael @vbatts time to move to easyjson?. https://github.com/mailru/easyjson |
Through 6734c7a (Merge pull request opencontainers#370 from vbatts/json_schema_and_examples, 2016-04-11). The only unlisted changes to master were a brief run with ffjson (opencontainers#343, opencontainers#351), but that was pulled out due to gccgo issues in opencontainers#363. Signed-off-by: W. Trevor King <wking@tremily.us>
Through 6734c7a (Merge pull request opencontainers#370 from vbatts/json_schema_and_examples, 2016-04-11). The only unlisted changes to master were a brief run with ffjson (opencontainers#343, opencontainers#351), but that was pulled out due to gccgo issues in opencontainers#363. Signed-off-by: W. Trevor King <wking@tremily.us>
Through 6734c7a (Merge pull request opencontainers#370 from vbatts/json_schema_and_examples, 2016-04-11). The only unlisted changes to master were a brief run with ffjson (opencontainers#343, opencontainers#351), but that was pulled out due to gccgo issues in opencontainers#363. Signed-off-by: W. Trevor King <wking@tremily.us>
Through 6734c7a (Merge pull request opencontainers#370 from vbatts/json_schema_and_examples, 2016-04-11). The only unlisted changes to master were a brief run with ffjson (opencontainers#343, opencontainers#351), but that was pulled out due to gccgo issues in opencontainers#363. Signed-off-by: W. Trevor King <wking@tremily.us>
By using ffjson for json encoding we can reduce the time for encoding
and decoding.
Without:
BenchmarkMarsalSpec-4 100000 18276 ns/op
BenchmarkUnmarshal-4 30000 55115 ns/op
With:
BenchmarkMarsalSpec-4 100000 13649 ns/op
BenchmarkUnmarshal-4 50000 24747 ns/op
This is a reduces time about 25% on marshal and 50% on unmarshal.
I think its worth it to use ffjson as there is really no changes other than needing to generate the code after a change and we get good benefits in return.