Uh oh!
There was an error while loading. Please reload this page.
Improve json encoding performance for specs-go - #343
Merged
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>
vbatts
commented
Mar 16, 2016
Member
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? |
crosbymichael
commented
Mar 16, 2016
MemberAuthor
@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 |
jessfraz
commented
Mar 16, 2016
imma use it 😇 i just updated all my tools |
vbatts
commented
Mar 16, 2016
Member
Then ought we put a target in the |
crosbymichael
commented
Mar 16, 2016
MemberAuthor
@vbatts updated makefile |
| }, | ||
| } | ||
| func BenchmarkMarsalSpec(b *testing.B) { |
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
crosbymichaelforce-pushed
the
marshal-performance
branch
from
March 16, 2016 18:30
d041388 to
cfec788Comparemrunalp
commented
Mar 16, 2016
Contributor
LGTM |
| .gitvalidation: | ||
| git-validation -q -run DCO,short-subject -v -range $(EPOCH_TEST_COMMIT)..HEAD | ||
| # `go get https://github.com/pquerna/ffjson` |
vbatts
commented
Mar 17, 2016
Member
LGTM beside silly nit |
vbatts added a commit
that referenced
this pull request
Mar 17, 2016
Improve json encoding performance for specs-go
marcosnils
commented
Mar 25, 2016
@crosbymichael@vbatts time to move to easyjson?. https://github.com/mailru/easyjson |
wking added a commit
to wking/opencontainer-runtime-spec
that referenced
this pull request
Apr 12, 2016
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>
wking added a commit
to wking/opencontainer-runtime-spec
that referenced
this pull request
Apr 12, 2016
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>
vbatts pushed a commit
to vbatts/oci-runtime-spec
that referenced
this pull request
Apr 12, 2016
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>
Mashimiao pushed a commit
to Mashimiao/specs
that referenced
this pull request
Aug 19, 2016
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.