aws / aws-lambda-go

Libraries, samples and tools to help Go developers develop AWS Lambda functions.
Apache License 2.0
3.58k stars 548 forks source link

Replace standard json library by segmentio's library #527

Closed dcu closed 8 months ago

dcu commented 8 months ago

The segmentio json library is a drop-in replacement that it's faster than the standard library. In this case it's ~37% faster.

goos: darwin
goarch: arm64
pkg: github.com/aws/aws-lambda-go/lambda
       │ bench.orig.txt │           bench.json.txt            │
       │     sec/op     │   sec/op     vs base                │
JSON-8      7.901µ ± 0%   4.985µ ± 0%  -36.90% (p=0.000 n=40)

       │ bench.orig.txt │             bench.json.txt             │
       │      B/op      │     B/op       vs base                 │
JSON-8     4.353Ki ± 0%   38.273Ki ± 0%  +779.34% (p=0.000 n=40)

       │ bench.orig.txt │       bench.json.txt       │
       │   allocs/op    │ allocs/op   vs base        │
JSON-8       31.00 ± 0%   17.00 ± 0%  -45.16% (n=40)

re #381

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

codecov-commenter commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c4e28da) 72.63% compared to head (c58d997) 72.63%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #527 +/- ## ======================================= Coverage 72.63% 72.63% ======================================= Files 26 26 Lines 1407 1407 ======================================= Hits 1022 1022 Misses 314 314 Partials 71 71 ``` | [Files](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws) | Coverage Δ | | |---|---|---| | [cfn/response.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-Y2ZuL3Jlc3BvbnNlLmdv) | `69.44% <ø> (ø)` | | | [cfn/wrap.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-Y2ZuL3dyYXAuZ28=) | `66.66% <ø> (ø)` | | | [events/attributevalue.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-ZXZlbnRzL2F0dHJpYnV0ZXZhbHVlLmdv) | `78.46% <ø> (ø)` | | | [events/cloudwatch\_logs.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-ZXZlbnRzL2Nsb3Vkd2F0Y2hfbG9ncy5nbw==) | `60.00% <ø> (ø)` | | | [events/codebuild.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-ZXZlbnRzL2NvZGVidWlsZC5nbw==) | `40.90% <ø> (ø)` | | | [events/duration.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-ZXZlbnRzL2R1cmF0aW9uLmdv) | `40.00% <ø> (ø)` | | | [events/ecs\_container\_instance.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-ZXZlbnRzL2Vjc19jb250YWluZXJfaW5zdGFuY2UuZ28=) | `81.25% <ø> (ø)` | | | [events/epoch\_time.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-ZXZlbnRzL2Vwb2NoX3RpbWUuZ28=) | `72.72% <ø> (ø)` | | | [events/kafka.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-ZXZlbnRzL2thZmthLmdv) | `81.25% <ø> (ø)` | | | [events/lambda\_function\_urls.go](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws#diff-ZXZlbnRzL2xhbWJkYV9mdW5jdGlvbl91cmxzLmdv) | `79.41% <ø> (ø)` | | | ... and [5 more](https://app.codecov.io/gh/aws/aws-lambda-go/pull/527?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws) | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

bmoffatt commented 8 months ago

I'm not comfortable expanding the dependencies of aws-lambda-go beyond that of Go's standard library.