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 jackson to snake case for better performance #382

Merged
merged 4 commits into from
May 22, 2023
Merged

Conversation

rudygt
Copy link
Contributor

@rudygt rudygt commented May 14, 2023

Description of changes:

Hello, I am big fan of making things faster and originally was trying to avoid some String.replaceAll calls in TracingHandler, but found that you already have a better StringTransform implementation but not using it there,

after looking more deeply I found that using the SnakeCaseStrategy from PropertyNamingStrategies that is already highly optimized was the best route.

Thanks.

ps. I checked the performance using this branch https://github.com/rudygt/aws-xray-sdk-java/tree/benchmark, I dont think merging that test is needed. this is the output I get on my system.

Benchmark                                                           Mode      Cnt     Score      Error   Units
SnakeCaseBenchmark.jacksonSnakeCase                                thrpt        5    27.105 �    0.527  ops/us
SnakeCaseBenchmark.jacksonSnakeCase:�gc.alloc.rate                 thrpt        5  7155.905 �   96.815  MB/sec
SnakeCaseBenchmark.jacksonSnakeCase:�gc.alloc.rate.norm            thrpt        5   416.000 �    0.001    B/op
SnakeCaseBenchmark.jacksonSnakeCase:�gc.churn.G1_Eden_Space        thrpt        5  7087.917 � 1873.788  MB/sec
SnakeCaseBenchmark.jacksonSnakeCase:�gc.churn.G1_Eden_Space.norm   thrpt        5   411.981 �  104.107    B/op
SnakeCaseBenchmark.jacksonSnakeCase:�gc.churn.G1_Old_Gen           thrpt        5     0.003 �    0.004  MB/sec
SnakeCaseBenchmark.jacksonSnakeCase:�gc.churn.G1_Old_Gen.norm      thrpt        5    ? 10??               B/op
SnakeCaseBenchmark.jacksonSnakeCase:�gc.count                      thrpt        5    38.000             counts
SnakeCaseBenchmark.jacksonSnakeCase:�gc.time                       thrpt        5    30.000                 ms
SnakeCaseBenchmark.ownSnakeCase                                    thrpt        5     4.139 �    0.131  ops/us
SnakeCaseBenchmark.ownSnakeCase:�gc.alloc.rate                     thrpt        5  5303.713 �  174.552  MB/sec
SnakeCaseBenchmark.ownSnakeCase:�gc.alloc.rate.norm                thrpt        5  2024.002 �    0.001    B/op
SnakeCaseBenchmark.ownSnakeCase:�gc.churn.G1_Eden_Space            thrpt        5  5294.799 � 1334.128  MB/sec
SnakeCaseBenchmark.ownSnakeCase:�gc.churn.G1_Eden_Space.norm       thrpt        5  2019.998 �  456.831    B/op
SnakeCaseBenchmark.ownSnakeCase:�gc.churn.G1_Old_Gen               thrpt        5     0.003 �    0.006  MB/sec
SnakeCaseBenchmark.ownSnakeCase:�gc.churn.G1_Old_Gen.norm          thrpt        5     0.001 �    0.002    B/op
SnakeCaseBenchmark.ownSnakeCase:�gc.count                          thrpt        5    42.000             counts
SnakeCaseBenchmark.ownSnakeCase:�gc.time                           thrpt        5    29.000                 ms
SnakeCaseBenchmark.jacksonSnakeCase                               sample  2103354     0.650 �    0.012   us/op
SnakeCaseBenchmark.jacksonSnakeCase:jacksonSnakeCase�p0.00        sample              0.400              us/op
SnakeCaseBenchmark.jacksonSnakeCase:jacksonSnakeCase�p0.50        sample              0.500              us/op
SnakeCaseBenchmark.jacksonSnakeCase:jacksonSnakeCase�p0.90        sample              0.900              us/op
SnakeCaseBenchmark.jacksonSnakeCase:jacksonSnakeCase�p0.95        sample              0.900              us/op
SnakeCaseBenchmark.jacksonSnakeCase:jacksonSnakeCase�p0.99        sample              0.900              us/op
SnakeCaseBenchmark.jacksonSnakeCase:jacksonSnakeCase�p0.999       sample              3.700              us/op
SnakeCaseBenchmark.jacksonSnakeCase:jacksonSnakeCase�p0.9999      sample             34.048              us/op
SnakeCaseBenchmark.jacksonSnakeCase:jacksonSnakeCase�p1.00        sample           1634.304              us/op
SnakeCaseBenchmark.jacksonSnakeCase:�gc.alloc.rate                sample        5  7028.249 �  184.340  MB/sec
SnakeCaseBenchmark.jacksonSnakeCase:�gc.alloc.rate.norm           sample        5   416.135 �    0.013    B/op
SnakeCaseBenchmark.jacksonSnakeCase:�gc.churn.G1_Eden_Space       sample        5  7031.250 � 1664.497  MB/sec
SnakeCaseBenchmark.jacksonSnakeCase:�gc.churn.G1_Eden_Space.norm  sample        5   416.249 �   92.975    B/op
SnakeCaseBenchmark.jacksonSnakeCase:�gc.churn.G1_Old_Gen          sample        5     0.002 �    0.009  MB/sec
SnakeCaseBenchmark.jacksonSnakeCase:�gc.churn.G1_Old_Gen.norm     sample        5    ? 10??               B/op
SnakeCaseBenchmark.jacksonSnakeCase:�gc.count                     sample        5    43.000             counts
SnakeCaseBenchmark.jacksonSnakeCase:�gc.time                      sample        5    34.000                 ms
SnakeCaseBenchmark.ownSnakeCase                                   sample  2674887     3.737 �    0.024   us/op
SnakeCaseBenchmark.ownSnakeCase:ownSnakeCase�p0.00                sample              2.500              us/op
SnakeCaseBenchmark.ownSnakeCase:ownSnakeCase�p0.50                sample              2.900              us/op
SnakeCaseBenchmark.ownSnakeCase:ownSnakeCase�p0.90                sample              4.696              us/op
SnakeCaseBenchmark.ownSnakeCase:ownSnakeCase�p0.95                sample              4.800              us/op
SnakeCaseBenchmark.ownSnakeCase:ownSnakeCase�p0.99                sample              5.000              us/op
SnakeCaseBenchmark.ownSnakeCase:ownSnakeCase�p0.999               sample             16.576              us/op
SnakeCaseBenchmark.ownSnakeCase:ownSnakeCase�p0.9999              sample            100.668              us/op
SnakeCaseBenchmark.ownSnakeCase:ownSnakeCase�p1.00                sample           1898.496              us/op
SnakeCaseBenchmark.ownSnakeCase:�gc.alloc.rate                    sample        5  5664.450 �  574.098  MB/sec
SnakeCaseBenchmark.ownSnakeCase:�gc.alloc.rate.norm               sample        5  2024.767 �    0.167    B/op
SnakeCaseBenchmark.ownSnakeCase:�gc.churn.G1_Eden_Space           sample        5  5763.147 � 1199.824  MB/sec
SnakeCaseBenchmark.ownSnakeCase:�gc.churn.G1_Eden_Space.norm      sample        5  2060.170 �  379.310    B/op
SnakeCaseBenchmark.ownSnakeCase:�gc.churn.G1_Old_Gen              sample        5     0.007 �    0.022  MB/sec
SnakeCaseBenchmark.ownSnakeCase:�gc.churn.G1_Old_Gen.norm         sample        5     0.003 �    0.008    B/op
SnakeCaseBenchmark.ownSnakeCase:�gc.count                         sample        5    41.000             counts
SnakeCaseBenchmark.ownSnakeCase:�gc.time                          sample        5    36.000                 ms

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rudygt rudygt requested a review from a team as a code owner May 14, 2023 12:51
@codecov-commenter
Copy link

codecov-commenter commented May 22, 2023

Codecov Report

Attention: Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.

Project coverage is 28.09%. Comparing base (4103ea0) to head (bdb6640).
Report is 25 commits behind head on master.

Files with missing lines Patch % Lines
...va/com/amazonaws/xray/handlers/TracingHandler.java 50.00% 4 Missing ⚠️
...mazonaws/xray/interceptors/TracingInterceptor.java 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #382      +/-   ##
============================================
+ Coverage     28.07%   28.09%   +0.01%     
+ Complexity      575      574       -1     
============================================
  Files           138      138              
  Lines          5253     5254       +1     
  Branches        634      634              
============================================
+ Hits           1475     1476       +1     
  Misses         3577     3577              
  Partials        201      201              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wangzlei wangzlei merged commit 37655e2 into aws:master May 22, 2023
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.

3 participants