Skip to content

Improve marshal speed #47

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 5 commits into from
Nov 24, 2021
Merged

Conversation

klauspost
Copy link
Collaborator

@klauspost klauspost commented Nov 16, 2021

  • Add fast case for non-escaped inputs.
  • Add specialized float printing.
benchmark                                             old ns/op     new ns/op     delta
BenchmarkIter_MarshalJSONBuffer/apache_builds-32      287323        148202        -48.42%
BenchmarkIter_MarshalJSONBuffer/canada-32             13529136      10290900      -23.94%
BenchmarkIter_MarshalJSONBuffer/citm_catalog-32       1727759       1231152       -28.74%
BenchmarkIter_MarshalJSONBuffer/github_events-32      147846        72801         -50.76%
BenchmarkIter_MarshalJSONBuffer/gsoc-2018-32          7302709       3186714       -56.36%
BenchmarkIter_MarshalJSONBuffer/instruments-32        405617        249186        -38.57%
BenchmarkIter_MarshalJSONBuffer/numbers-32            1114819       803988        -27.88%
BenchmarkIter_MarshalJSONBuffer/marine_ik-32          15554551      13492569      -13.26%
BenchmarkIter_MarshalJSONBuffer/mesh-32               4519934       3556764       -21.31%
BenchmarkIter_MarshalJSONBuffer/mesh.pretty-32        4542054       3540605       -22.05%
BenchmarkIter_MarshalJSONBuffer/twitterescaped-32     1361729       653521        -52.01%
BenchmarkIter_MarshalJSONBuffer/twitter-32            1361365       635662        -53.31%
BenchmarkIter_MarshalJSONBuffer/random-32             1593711       927722        -41.79%
BenchmarkIter_MarshalJSONBuffer/update-center-32      1599886       778478        -51.34%

benchmark                                             old MB/s     new MB/s     speedup
BenchmarkIter_MarshalJSONBuffer/apache_builds-32      329.43       638.68       1.94x
BenchmarkIter_MarshalJSONBuffer/canada-32             154.50       203.11       1.31x
BenchmarkIter_MarshalJSONBuffer/citm_catalog-32       289.57       406.37       1.40x
BenchmarkIter_MarshalJSONBuffer/github_events-32      360.71       732.54       2.03x
BenchmarkIter_MarshalJSONBuffer/gsoc-2018-32          420.40       963.39       2.29x
BenchmarkIter_MarshalJSONBuffer/instruments-32        267.03       434.67       1.63x
BenchmarkIter_MarshalJSONBuffer/numbers-32            134.66       186.72       1.39x
BenchmarkIter_MarshalJSONBuffer/marine_ik-32          117.59       135.56       1.15x
BenchmarkIter_MarshalJSONBuffer/mesh-32               142.19       180.70       1.27x
BenchmarkIter_MarshalJSONBuffer/mesh.pretty-32        141.50       181.52       1.28x
BenchmarkIter_MarshalJSONBuffer/twitterescaped-32     342.88       714.45       2.08x
BenchmarkIter_MarshalJSONBuffer/twitter-32            342.97       734.52       2.14x
BenchmarkIter_MarshalJSONBuffer/random-32             289.55       497.42       1.72x
BenchmarkIter_MarshalJSONBuffer/update-center-32      333.12       684.62       2.06x

Add fast case for non-escaped inputs. Escaped values take a small penalty, but it seems like an overall gain.

```
benchmark                                             old ns/op     new ns/op     delta
BenchmarkIter_MarshalJSONBuffer/apache_builds-32      287323        152872        -46.79%
BenchmarkIter_MarshalJSONBuffer/canada-32             13529136      13336691      -1.42%
BenchmarkIter_MarshalJSONBuffer/citm_catalog-32       1727759       1285843       -25.58%
BenchmarkIter_MarshalJSONBuffer/github_events-32      147846        72136         -51.21%
BenchmarkIter_MarshalJSONBuffer/gsoc-2018-32          7302709       3198392       -56.20%
BenchmarkIter_MarshalJSONBuffer/instruments-32        405617        247097        -39.08%
BenchmarkIter_MarshalJSONBuffer/numbers-32            1114819       1098031       -1.51%
BenchmarkIter_MarshalJSONBuffer/marine_ik-32          15554551      14718475      -5.38%
BenchmarkIter_MarshalJSONBuffer/mesh-32               4519934       4387538       -2.93%
BenchmarkIter_MarshalJSONBuffer/mesh.pretty-32        4542054       4366635       -3.86%
BenchmarkIter_MarshalJSONBuffer/twitterescaped-32     1361729       655030        -51.90%
BenchmarkIter_MarshalJSONBuffer/twitter-32            1361365       650635        -52.21%
BenchmarkIter_MarshalJSONBuffer/random-32             1593711       933206        -41.44%
BenchmarkIter_MarshalJSONBuffer/update-center-32      1599886       781166        -51.17%

benchmark                                             old MB/s     new MB/s     speedup
BenchmarkIter_MarshalJSONBuffer/apache_builds-32      329.43       619.17       1.88x
BenchmarkIter_MarshalJSONBuffer/canada-32             154.50       156.73       1.01x
BenchmarkIter_MarshalJSONBuffer/citm_catalog-32       289.57       389.08       1.34x
BenchmarkIter_MarshalJSONBuffer/github_events-32      360.71       739.29       2.05x
BenchmarkIter_MarshalJSONBuffer/gsoc-2018-32          420.40       959.87       2.28x
BenchmarkIter_MarshalJSONBuffer/instruments-32        267.03       438.34       1.64x
BenchmarkIter_MarshalJSONBuffer/numbers-32            134.66       136.72       1.02x
BenchmarkIter_MarshalJSONBuffer/marine_ik-32          117.59       124.27       1.06x
BenchmarkIter_MarshalJSONBuffer/mesh-32               142.19       146.48       1.03x
BenchmarkIter_MarshalJSONBuffer/mesh.pretty-32        141.50       147.18       1.04x
BenchmarkIter_MarshalJSONBuffer/twitterescaped-32     342.88       712.80       2.08x
BenchmarkIter_MarshalJSONBuffer/twitter-32            342.97       717.62       2.09x
BenchmarkIter_MarshalJSONBuffer/random-32             289.55       494.50       1.71x
BenchmarkIter_MarshalJSONBuffer/update-center-32      333.12       682.26       2.05x
```
@klauspost klauspost force-pushed the faster-string-escaping branch from 5b9bca5 to 4e970fb Compare November 16, 2021 15:57
@klauspost klauspost changed the title Improve escaping speed Improve marshal speed Nov 17, 2021
# Conflicts:
#	parsed_json_test.go
@klauspost klauspost merged commit d9aecff into minio:master Nov 24, 2021
@klauspost klauspost deleted the faster-string-escaping branch November 24, 2021 11:20
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