Skip to content

Unsafe #91

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

Merged
merged 1 commit into from
Jul 24, 2019
Merged

Unsafe #91

merged 1 commit into from
Jul 24, 2019

Conversation

lavalamp
Copy link
Contributor

@lavalamp lavalamp commented Jul 24, 2019

Only the last commit is new. These numbers are for just that commit.

benchmark                                 old ns/op     new ns/op     delta
BenchmarkFieldSet/serialize-20-12         27360         15191         -44.48%
BenchmarkFieldSet/deserialize-20-12       35718         35840         +0.34%
BenchmarkFieldSet/serialize-50-12         57494         37869         -34.13%
BenchmarkFieldSet/deserialize-50-12       86494         82157         -5.01%
BenchmarkFieldSet/serialize-100-12        170144        111428        -34.51%
BenchmarkFieldSet/deserialize-100-12      223283        224378        +0.49%
BenchmarkFieldSet/serialize-500-12        919350        597742        -34.98%
BenchmarkFieldSet/deserialize-500-12      1084716       1062631       -2.04%
BenchmarkFieldSet/serialize-1000-12       1786525       1167377       -34.66%
BenchmarkFieldSet/deserialize-1000-12     1950813       2292026       +17.49%

benchmark                                 old allocs     new allocs     delta
BenchmarkFieldSet/serialize-20-12         110            25             -77.27%
BenchmarkFieldSet/deserialize-20-12       216            216            +0.00%
BenchmarkFieldSet/serialize-50-12         300            50             -83.33%
BenchmarkFieldSet/deserialize-50-12       616            614            -0.32%
BenchmarkFieldSet/serialize-100-12        1032           95             -90.79%
BenchmarkFieldSet/deserialize-100-12      2167           2166           -0.05%
BenchmarkFieldSet/serialize-500-12        5701           472            -91.72%
BenchmarkFieldSet/deserialize-500-12      10770          10779          +0.08%
BenchmarkFieldSet/serialize-1000-12       12365          1000           -91.91%
BenchmarkFieldSet/deserialize-1000-12     23523          23534          +0.05%

Unfortunately I don't think I can give deserialize the same treatment without making jsoniter changes :/

Note that this makes use of the unsafe package, I need changes to jsoniter to avoid that.

Jsoniter's pools are apparently... not for the purpose of doing optimal memory management.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 24, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lavalamp

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 24, 2019
@lavalamp
Copy link
Contributor Author

This brings the total improvement to:

benchmark                       old ns/op     new ns/op     delta
BenchmarkApplyNewObject-12      2230683       1933055       -13.34%
BenchmarkUpdateNewObject-12     2624417       2236517       -14.78%
BenchmarkRepeatedUpdate-12      1031653       755754        -26.74%
BenchmarkSetToFields-12         24778         5078          -79.51%
BenchmarkFieldsToSet-12         33876         10309         -69.57%
BenchmarkYAMLToTyped-12         68377         65714         -3.89%

benchmark                       old allocs     new allocs     delta
BenchmarkApplyNewObject-12      8632           6827           -20.91%
BenchmarkUpdateNewObject-12     11210          7913           -29.41%
BenchmarkRepeatedUpdate-12      3057           2288           -25.16%
BenchmarkSetToFields-12         124            15             -87.90%
BenchmarkFieldsToSet-12         147            82             -44.22%
BenchmarkYAMLToTyped-12         150            152            +1.33%

@lavalamp
Copy link
Contributor Author

The unsafe bit is key, sadly-- removing it I get

benchmark                                 old allocs     new allocs     delta
BenchmarkFieldSet/serialize-20-12         25             96             +284.00%
BenchmarkFieldSet/deserialize-20-12       216            216            +0.00%
BenchmarkFieldSet/serialize-50-12         50             254            +408.00%
BenchmarkFieldSet/deserialize-50-12       614            616            +0.33%
BenchmarkFieldSet/serialize-100-12        95             803            +745.26%
BenchmarkFieldSet/deserialize-100-12      2166           2168           +0.09%
BenchmarkFieldSet/serialize-500-12        472            4013           +750.21%
BenchmarkFieldSet/deserialize-500-12      10779          10773          -0.06%
BenchmarkFieldSet/serialize-1000-12       1000           8654           +765.40%
BenchmarkFieldSet/deserialize-1000-12     23534          23511          -0.10%

@lavalamp
Copy link
Contributor Author

json-iterator/go#393

@lavalamp
Copy link
Contributor Author

lavalamp commented Jul 24, 2019

I've modified this to do a less unsafe thing with the unsafe package. (performance is the same.)

@apelisse
Copy link
Contributor

apelisse commented Jul 24, 2019

I think this is OK. I don't have much knowledge about jsoniter though.

@apelisse
Copy link
Contributor

/lgtm

Should we rebase before merging?
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 24, 2019
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 24, 2019
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 24, 2019
@apelisse
Copy link
Contributor

/lgtm
/hold cancel

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jul 24, 2019
@lavalamp
Copy link
Contributor Author

rebased, but I see you already noticed... :)

@k8s-ci-robot k8s-ci-robot merged commit 0c1d754 into kubernetes-sigs:master Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants