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

Use ugorji codec for unmarshalling key responses in client #3308

Merged
merged 3 commits into from
Sep 1, 2015

Conversation

yichengq
Copy link
Contributor

This change speeds up response unmarshal ~2x:

BEFORE:

BenchmarkSmallResponseUnmarshal   10000    164524 ns/op
BenchmarkManySmallResponseUnmarshal     100  13916636 ns/op
BenchmarkMediumResponseUnmarshal       1000   1974295 ns/op
BenchmarkLargeResponseUnmarshal      20  80462001 ns/op

AFTER:

BenchmarkSmallResponseUnmarshal    20000         75243 ns/op
BenchmarkManySmallResponseUnmarshal      200       6629661 ns/op
BenchmarkMediumResponseUnmarshal        1000       1359041 ns/op
BenchmarkLargeResponseUnmarshal       20      61600978 ns/op

Its performance is nearly the same as the one benchmarked in coreos/go-etcd#218. So two packages perform similarly.

@wojtek-t
I have attempted to use ffjson, but it doesn't perform as well as codec. Here is its benchmark:

BenchmarkSmallResponseUnmarshal   10000    117718 ns/op
BenchmarkManySmallResponseUnmarshal     100  10459107 ns/op
BenchmarkMediumResponseUnmarshal       1000   1659496 ns/op
BenchmarkLargeResponseUnmarshal      20  74711133 ns/op

So I still use codec in etcd/client pkg.

/cc @fgrzadkowski @wojtek-t @timothysc

fixes #3193
ref kubernetes/kubernetes#11962

The benchmark result:

```
BenchmarkSmallResponseUnmarshal	  10000	   164524 ns/op
BenchmarkManySmallResponseUnmarshal	    100	 13916636 ns/op
BenchmarkMediumResponseUnmarshal	   1000	  1974295 ns/op
BenchmarkLargeResponseUnmarshal	     20	 80462001 ns/op
ok		github.com/coreos/etcd/client	7.777s
```
This change speeds up response unmarshal ~2x:

```
BenchmarkSmallResponseUnmarshal	   20000	     75243 ns/op
BenchmarkManySmallResponseUnmarshal	     200	   6629661 ns/op
BenchmarkMediumResponseUnmarshal	    1000	   1359041 ns/op
BenchmarkLargeResponseUnmarshal	      20	  61600978 ns/op
```
@wojtek-t
Copy link
Contributor

Thanks for comparison of ffjson & ugorij - this is really useful.

@fgrzadkowski - since you added that codec to the previous client, can you please take a look?

@wojtek-t
Copy link
Contributor

Since @fgrzadkowski is OOO, I think it doesn't make sence to block on him.

I looked into it and it LGTM.

@timothysc
Copy link

@yichengq just checking in on the status here...

@wojtek-t
Copy link
Contributor

wojtek-t commented Sep 1, 2015

Yes - I think it would be great if you could merge it soon - I will be trying to use new etcd client in kubernetes soon.

@xiang90
Copy link
Contributor

xiang90 commented Sep 1, 2015

LGTM

yichengq added a commit that referenced this pull request Sep 1, 2015
Use ugorji codec for unmarshalling key responses in client
@yichengq yichengq merged commit d412eaa into etcd-io:master Sep 1, 2015
@yichengq yichengq deleted the go-codec branch September 1, 2015 21:04
@timothysc
Copy link

/cc @danmcp - Fast unmarshaling which will also feed through the updated client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

use fast unmarshalJson code in etcd/client
4 participants