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

Optimize is_card_number to use array #678

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

bantonsson
Copy link
Contributor

@bantonsson bantonsson commented Oct 15, 2024

What does this PR do?

Use a fixed size array (we know that credit card numbers are at most 16 digits long) instead of a dynamic Vec.

Motivation

While looking at benchmark fluctuations, I saw that the code seemed to do unnecessary operations. Why not optimize it?

@bantonsson bantonsson force-pushed the ban/use-array-in-is-card-number branch from c9453f0 to 60e0f3b Compare October 15, 2024 15:59
@pr-commenter
Copy link

pr-commenter bot commented Oct 15, 2024

Benchmarks

Comparison

Benchmark execution time: 2024-10-22 06:28:04

Comparing candidate commit 1955f2e in PR branch ban/use-array-in-is-card-number with baseline commit 6e2d784 in branch main.

Found 23 performance improvements and 0 performance regressions! Performance is the same for 28 metrics, 2 unstable metrics.

scenario:benching deserializing traces from msgpack to their internal representation

  • 🟩 execution_time [-41.733ns; -32.930ns] or [-3.436%; -2.711%]

scenario:credit_card/is_card_number/ 3782-8224-6310-005

  • 🟩 execution_time [-29.503µs; -29.231µs] or [-24.452%; -24.227%]
  • 🟩 throughput [+2654588.361op/s; +2677873.741op/s] or [+32.027%; +32.308%]

scenario:credit_card/is_card_number/ 378282246310005

  • 🟩 execution_time [-29.144µs; -28.922µs] or [-25.879%; -25.682%]
  • 🟩 throughput [+3072228.566op/s; +3096953.035op/s] or [+34.598%; +34.876%]

scenario:credit_card/is_card_number/378282246310005

  • 🟩 execution_time [-28.530µs; -28.307µs] or [-26.220%; -26.014%]
  • 🟩 throughput [+3236534.185op/s; +3260803.951op/s] or [+35.216%; +35.480%]

scenario:credit_card/is_card_number/37828224631000521389798

  • 🟩 execution_time [-59.549µs; -59.409µs] or [-50.082%; -49.965%]
  • 🟩 throughput [+8409879.525op/s; +8426260.128op/s] or [+99.994%; +100.189%]

scenario:credit_card/is_card_number/x371413321323331

  • 🟩 execution_time [-19.972µs; -19.866µs] or [-73.584%; -73.192%]
  • 🟩 throughput [+101523927.245op/s; +101671004.469op/s] or [+275.500%; +275.899%]

scenario:credit_card/is_card_number_no_luhn/ 3782-8224-6310-005

  • 🟩 execution_time [-30.434µs; -30.279µs] or [-29.047%; -28.899%]
  • 🟩 throughput [+3884971.162op/s; +3900934.683op/s] or [+40.704%; +40.872%]

scenario:credit_card/is_card_number_no_luhn/ 378282246310005

  • 🟩 execution_time [-29.618µs; -29.390µs] or [-30.736%; -30.500%]
  • 🟩 throughput [+4565202.402op/s; +4592728.927op/s] or [+43.989%; +44.254%]

scenario:credit_card/is_card_number_no_luhn/378282246310005

  • 🟩 execution_time [-30.034µs; -29.776µs] or [-32.446%; -32.167%]
  • 🟩 throughput [+5138869.578op/s; +5170681.833op/s] or [+47.564%; +47.859%]

scenario:credit_card/is_card_number_no_luhn/37828224631000521389798

  • 🟩 execution_time [-59.515µs; -59.364µs] or [-50.038%; -49.912%]
  • 🟩 throughput [+8390192.931op/s; +8408564.118op/s] or [+99.790%; +100.008%]

scenario:credit_card/is_card_number_no_luhn/x371413321323331

  • 🟩 execution_time [-19.881µs; -19.774µs] or [-73.496%; -73.100%]
  • 🟩 throughput [+101399718.533op/s; +101544789.361op/s] or [+274.233%; +274.625%]

scenario:redis/obfuscate_redis_string

  • 🟩 execution_time [-2.517µs; -2.144µs] or [-6.143%; -5.233%]

scenario:tags/replace_trace_tags

  • 🟩 execution_time [-290.511ns; -282.983ns] or [-9.874%; -9.618%]

Candidate

Candidate benchmark details

Group 1

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... execution_time 623.201µs 624.454µs ± 0.381µs 624.448µs ± 0.229µs 624.686µs 625.114µs 625.279µs 626.006µs 0.25% 0.129 1.374 0.06% 0.027µs 1 200
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput 1597428.050op/s 1601398.865op/s ± 977.399op/s 1601414.919op/s ± 587.794op/s 1601904.161op/s 1602986.501op/s 1603699.841op/s 1604617.815op/s 0.20% -0.123 1.367 0.06% 69.113op/s 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time 461.065µs 461.778µs ± 0.447µs 461.731µs ± 0.231µs 461.983µs 462.374µs 462.939µs 465.750µs 0.87% 3.713 29.616 0.10% 0.032µs 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput 2147074.126op/s 2165544.608op/s ± 2091.084op/s 2165764.664op/s ± 1083.933op/s 2166793.182op/s 2168055.993op/s 2168659.775op/s 2168893.321op/s 0.14% -3.662 29.021 0.10% 147.862op/s 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time 178.014µs 178.351µs ± 0.166µs 178.355µs ± 0.106µs 178.457µs 178.558µs 178.665µs 179.282µs 0.52% 1.009 4.988 0.09% 0.012µs 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput 5577807.133op/s 5606922.212op/s ± 5198.707op/s 5606803.688op/s ± 3347.580op/s 5610173.910op/s 5615169.157op/s 5616848.881op/s 5617534.122op/s 0.19% -0.992 4.897 0.09% 367.604op/s 1 200
normalization/normalize_service/normalize_service/[empty string] execution_time 46.612µs 46.787µs ± 0.078µs 46.787µs ± 0.050µs 46.832µs 46.927µs 47.011µs 47.031µs 0.52% 0.340 0.354 0.17% 0.006µs 1 200
normalization/normalize_service/normalize_service/[empty string] throughput 21262533.290op/s 21373431.435op/s ± 35702.920op/s 21373390.882op/s ± 22646.523op/s 21397881.427op/s 21427238.480op/s 21453037.107op/s 21453890.905op/s 0.38% -0.329 0.341 0.17% 2524.578op/s 1 200
normalization/normalize_service/normalize_service/test_ASCII execution_time 48.551µs 49.255µs ± 0.322µs 49.255µs ± 0.201µs 49.442µs 49.822µs 49.887µs 50.765µs 3.07% 0.502 1.471 0.65% 0.023µs 1 200
normalization/normalize_service/normalize_service/test_ASCII throughput 19698475.670op/s 20303566.918op/s ± 132356.578op/s 20302445.298op/s ± 82810.353op/s 20386836.550op/s 20516384.825op/s 20567149.662op/s 20597000.332op/s 1.45% -0.441 1.259 0.65% 9359.023op/s 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... execution_time [624.401µs; 624.507µs] or [-0.008%; +0.008%] None None None
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput [1601263.407op/s; 1601534.323op/s] or [-0.008%; +0.008%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time [461.716µs; 461.840µs] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput [2165254.804op/s; 2165834.412op/s] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time [178.328µs; 178.374µs] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput [5606201.721op/s; 5607642.702op/s] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/[empty string] execution_time [46.776µs; 46.798µs] or [-0.023%; +0.023%] None None None
normalization/normalize_service/normalize_service/[empty string] throughput [21368483.354op/s; 21378379.517op/s] or [-0.023%; +0.023%] None None None
normalization/normalize_service/normalize_service/test_ASCII execution_time [49.210µs; 49.299µs] or [-0.091%; +0.091%] None None None
normalization/normalize_service/normalize_service/test_ASCII throughput [20285223.569op/s; 20321910.266op/s] or [-0.090%; +0.090%] None None None

Group 2

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
tags/replace_trace_tags execution_time 2.596µs 2.655µs ± 0.018µs 2.656µs ± 0.005µs 2.663µs 2.684µs 2.693µs 2.697µs 1.55% -1.518 3.944 0.68% 0.001µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
tags/replace_trace_tags execution_time [2.653µs; 2.658µs] or [-0.095%; +0.095%] None None None

Group 3

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
two way interface execution_time 18.216µs 24.011µs ± 10.489µs 18.867µs ± 0.224µs 29.704µs 38.292µs 41.858µs 94.844µs 402.69% 3.227 16.212 43.58% 0.742µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
two way interface execution_time [22.557µs; 25.464µs] or [-6.054%; +6.054%] None None None

Group 4

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
credit_card/is_card_number/ execution_time 4.600µs 4.614µs ± 0.002µs 4.614µs ± 0.001µs 4.615µs 4.618µs 4.620µs 4.622µs 0.17% -0.890 8.430 0.05% 0.000µs 1 200
credit_card/is_card_number/ throughput 216359990.275op/s 216721321.899op/s ± 103644.010op/s 216722723.379op/s ± 54687.839op/s 216780219.521op/s 216870872.561op/s 216904356.439op/s 217395229.945op/s 0.31% 0.904 8.512 0.05% 7328.738op/s 1 200
credit_card/is_card_number/ 3782-8224-6310-005 execution_time 90.220µs 91.287µs ± 0.520µs 91.214µs ± 0.297µs 91.540µs 92.081µs 92.613µs 94.947µs 4.09% 2.023 11.190 0.57% 0.037µs 1 200
credit_card/is_card_number/ 3782-8224-6310-005 throughput 10532140.214op/s 10954772.808op/s ± 61704.536op/s 10963173.711op/s ± 35716.153op/s 10994135.225op/s 11035278.461op/s 11065418.674op/s 11084034.718op/s 1.10% -1.874 9.944 0.56% 4363.170op/s 1 200
credit_card/is_card_number/ 378282246310005 execution_time 82.651µs 83.584µs ± 0.535µs 83.508µs ± 0.308µs 83.831µs 84.491µs 85.005µs 86.993µs 4.17% 1.673 7.291 0.64% 0.038µs 1 200
credit_card/is_card_number/ 378282246310005 throughput 11495229.528op/s 11964494.849op/s ± 75804.538op/s 11974887.464op/s ± 44295.875op/s 12017616.027op/s 12065067.868op/s 12084891.816op/s 12099089.120op/s 1.04% -1.554 6.413 0.63% 5360.190op/s 1 200
credit_card/is_card_number/37828224631 execution_time 4.603µs 4.615µs ± 0.003µs 4.615µs ± 0.002µs 4.617µs 4.621µs 4.625µs 4.629µs 0.30% 0.963 3.785 0.07% 0.000µs 1 200
credit_card/is_card_number/37828224631 throughput 216048139.553op/s 216673339.606op/s ± 141608.378op/s 216696110.305op/s ± 77278.328op/s 216764894.014op/s 216851455.562op/s 216882018.892op/s 217254063.037op/s 0.26% -0.954 3.774 0.07% 10013.224op/s 1 200
credit_card/is_card_number/378282246310005 execution_time 79.481µs 80.393µs ± 0.426µs 80.388µs ± 0.300µs 80.697µs 81.139µs 81.330µs 81.389µs 1.25% 0.196 -0.475 0.53% 0.030µs 1 200
credit_card/is_card_number/378282246310005 throughput 12286629.169op/s 12439241.749op/s ± 65834.022op/s 12439646.580op/s ± 46554.224op/s 12484920.090op/s 12544128.486op/s 12570797.243op/s 12581554.897op/s 1.14% -0.172 -0.485 0.53% 4655.168op/s 1 200
credit_card/is_card_number/37828224631000521389798 execution_time 59.264µs 59.424µs ± 0.173µs 59.345µs ± 0.068µs 59.532µs 59.757µs 60.066µs 60.075µs 1.23% 1.495 1.982 0.29% 0.012µs 1 200
credit_card/is_card_number/37828224631000521389798 throughput 16645844.499op/s 16828437.656op/s ± 48734.913op/s 16850619.261op/s ± 19423.507op/s 16863020.058op/s 16871965.682op/s 16872759.100op/s 16873624.687op/s 0.14% -1.480 1.912 0.29% 3446.079op/s 1 200
credit_card/is_card_number/x371413321323331 execution_time 7.217µs 7.223µs ± 0.007µs 7.222µs ± 0.002µs 7.224µs 7.227µs 7.229µs 7.306µs 1.16% 10.341 125.843 0.09% 0.000µs 1 200
credit_card/is_card_number/x371413321323331 throughput 136874289.316op/s 138448215.678op/s ± 125010.481op/s 138463694.819op/s ± 34503.014op/s 138493355.781op/s 138522726.039op/s 138538546.134op/s 138556406.313op/s 0.07% -10.284 124.832 0.09% 8839.576op/s 1 200
credit_card/is_card_number_no_luhn/ execution_time 4.601µs 4.614µs ± 0.002µs 4.614µs ± 0.001µs 4.616µs 4.617µs 4.618µs 4.619µs 0.10% -1.432 8.431 0.04% 0.000µs 1 200
credit_card/is_card_number_no_luhn/ throughput 216500795.900op/s 216721122.038op/s ± 96038.529op/s 216720127.799op/s ± 64287.920op/s 216781774.072op/s 216864813.327op/s 216895204.861op/s 217362294.520op/s 0.30% 1.443 8.517 0.04% 6790.950op/s 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time 73.708µs 74.420µs ± 0.172µs 74.419µs ± 0.084µs 74.505µs 74.681µs 74.757µs 75.348µs 1.25% 0.151 5.222 0.23% 0.012µs 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput 13271770.669op/s 13437281.493op/s ± 31062.257op/s 13437505.522op/s ± 15165.293op/s 13452418.460op/s 13483816.120op/s 13524185.463op/s 13567048.353op/s 0.96% -0.101 5.116 0.23% 2196.433op/s 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time 66.309µs 66.859µs ± 0.231µs 66.853µs ± 0.176µs 67.033µs 67.188µs 67.425µs 67.627µs 1.16% 0.124 -0.282 0.34% 0.016µs 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 throughput 14787056.042op/s 14957126.136op/s ± 51658.856op/s 14958085.202op/s ± 39284.957op/s 14996606.269op/s 15038511.301op/s 15045079.184op/s 15080965.178op/s 0.82% -0.107 -0.305 0.34% 3652.833op/s 1 200
credit_card/is_card_number_no_luhn/37828224631 execution_time 4.602µs 4.614µs ± 0.002µs 4.614µs ± 0.001µs 4.616µs 4.618µs 4.620µs 4.622µs 0.16% -0.437 4.272 0.05% 0.000µs 1 200
credit_card/is_card_number_no_luhn/37828224631 throughput 216374888.257op/s 216715129.450op/s ± 104153.511op/s 216725684.763op/s ± 64467.101op/s 216779633.553op/s 216854201.624op/s 216893090.949op/s 217298417.380op/s 0.26% 0.446 4.311 0.05% 7364.765op/s 1 200
credit_card/is_card_number_no_luhn/378282246310005 execution_time 62.320µs 62.662µs ± 0.164µs 62.633µs ± 0.120µs 62.768µs 62.973µs 63.050µs 63.137µs 0.80% 0.560 -0.340 0.26% 0.012µs 1 200
credit_card/is_card_number_no_luhn/378282246310005 throughput 15838581.101op/s 15958818.814op/s ± 41690.176op/s 15965934.287op/s ± 30556.369op/s 15995764.322op/s 16006394.557op/s 16036140.767op/s 16046330.570op/s 0.50% -0.550 -0.355 0.26% 2947.941op/s 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time 59.264µs 59.499µs ± 0.198µs 59.497µs ± 0.183µs 59.624µs 59.853µs 59.942µs 60.073µs 0.97% 0.521 -0.684 0.33% 0.014µs 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput 16646324.462op/s 16807229.993op/s ± 55777.745op/s 16807489.417op/s ± 51745.325op/s 16862412.426op/s 16871860.798op/s 16872645.936op/s 16873573.844op/s 0.39% -0.510 -0.707 0.33% 3944.082op/s 1 200
credit_card/is_card_number_no_luhn/x371413321323331 execution_time 7.219µs 7.223µs ± 0.002µs 7.223µs ± 0.002µs 7.225µs 7.226µs 7.230µs 7.231µs 0.10% 0.229 -0.128 0.03% 0.000µs 1 200
credit_card/is_card_number_no_luhn/x371413321323331 throughput 138300363.425op/s 138448025.388op/s ± 43586.392op/s 138439301.288op/s ± 32103.314op/s 138491617.795op/s 138512502.139op/s 138517335.167op/s 138531335.788op/s 0.07% -0.227 -0.132 0.03% 3082.023op/s 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
credit_card/is_card_number/ execution_time [4.614µs; 4.615µs] or [-0.007%; +0.007%] None None None
credit_card/is_card_number/ throughput [216706957.836op/s; 216735685.962op/s] or [-0.007%; +0.007%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 execution_time [91.215µs; 91.359µs] or [-0.079%; +0.079%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 throughput [10946221.152op/s; 10963324.463op/s] or [-0.078%; +0.078%] None None None
credit_card/is_card_number/ 378282246310005 execution_time [83.510µs; 83.658µs] or [-0.089%; +0.089%] None None None
credit_card/is_card_number/ 378282246310005 throughput [11953989.070op/s; 11975000.629op/s] or [-0.088%; +0.088%] None None None
credit_card/is_card_number/37828224631 execution_time [4.615µs; 4.616µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/37828224631 throughput [216653714.047op/s; 216692965.166op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/378282246310005 execution_time [80.334µs; 80.452µs] or [-0.073%; +0.073%] None None None
credit_card/is_card_number/378282246310005 throughput [12430117.787op/s; 12448365.712op/s] or [-0.073%; +0.073%] None None None
credit_card/is_card_number/37828224631000521389798 execution_time [59.400µs; 59.448µs] or [-0.040%; +0.040%] None None None
credit_card/is_card_number/37828224631000521389798 throughput [16821683.466op/s; 16835191.846op/s] or [-0.040%; +0.040%] None None None
credit_card/is_card_number/x371413321323331 execution_time [7.222µs; 7.224µs] or [-0.013%; +0.013%] None None None
credit_card/is_card_number/x371413321323331 throughput [138430890.428op/s; 138465540.928op/s] or [-0.013%; +0.013%] None None None
credit_card/is_card_number_no_luhn/ execution_time [4.614µs; 4.615µs] or [-0.006%; +0.006%] None None None
credit_card/is_card_number_no_luhn/ throughput [216707812.021op/s; 216734432.054op/s] or [-0.006%; +0.006%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time [74.396µs; 74.444µs] or [-0.032%; +0.032%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput [13432976.562op/s; 13441586.423op/s] or [-0.032%; +0.032%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time [66.827µs; 66.891µs] or [-0.048%; +0.048%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 throughput [14949966.715op/s; 14964285.556op/s] or [-0.048%; +0.048%] None None None
credit_card/is_card_number_no_luhn/37828224631 execution_time [4.614µs; 4.615µs] or [-0.007%; +0.007%] None None None
credit_card/is_card_number_no_luhn/37828224631 throughput [216700694.775op/s; 216729564.125op/s] or [-0.007%; +0.007%] None None None
credit_card/is_card_number_no_luhn/378282246310005 execution_time [62.639µs; 62.684µs] or [-0.036%; +0.036%] None None None
credit_card/is_card_number_no_luhn/378282246310005 throughput [15953040.956op/s; 15964596.671op/s] or [-0.036%; +0.036%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time [59.471µs; 59.526µs] or [-0.046%; +0.046%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput [16799499.734op/s; 16814960.252op/s] or [-0.046%; +0.046%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 execution_time [7.223µs; 7.223µs] or [-0.004%; +0.004%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 throughput [138441984.733op/s; 138454066.042op/s] or [-0.004%; +0.004%] None None None

Group 5

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
write only interface execution_time 1.355µs 3.203µs ± 1.393µs 3.055µs ± 0.026µs 3.080µs 3.119µs 13.894µs 14.943µs 389.21% 7.597 57.906 43.39% 0.099µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
write only interface execution_time [3.010µs; 3.396µs] or [-6.029%; +6.029%] None None None

Group 6

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
normalization/normalize_trace/test_trace execution_time 258.807ns 271.688ns ± 17.907ns 263.057ns ± 2.090ns 275.691ns 309.796ns 330.793ns 333.391ns 26.74% 1.933 3.014 6.57% 1.266ns 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
normalization/normalize_trace/test_trace execution_time [269.206ns; 274.170ns] or [-0.913%; +0.913%] None None None

Group 7

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
benching deserializing traces from msgpack to their internal representation execution_time 1.119µs 1.177µs ± 0.023µs 1.180µs ± 0.015µs 1.198µs 1.201µs 1.202µs 1.203µs 1.96% -1.008 0.231 1.95% 0.002µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
benching deserializing traces from msgpack to their internal representation execution_time [1.174µs; 1.181µs] or [-0.272%; +0.272%] None None None

Group 8

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... execution_time 188.609µs 192.852µs ± 1.556µs 192.814µs ± 1.054µs 193.878µs 195.151µs 196.316µs 198.616µs 3.01% 0.127 0.408 0.80% 0.110µs 1 200
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput 5034850.440op/s 5185656.452op/s ± 41812.738op/s 5186352.116op/s ± 28206.070op/s 5213254.535op/s 5252376.836op/s 5269783.699op/s 5301986.501op/s 2.23% -0.071 0.327 0.80% 2956.607op/s 1 200
normalization/normalize_name/normalize_name/bad-name execution_time 18.198µs 18.231µs ± 0.026µs 18.217µs ± 0.018µs 18.252µs 18.270µs 18.298µs 18.309µs 0.51% 0.497 -0.793 0.14% 0.002µs 1 200
normalization/normalize_name/normalize_name/bad-name throughput 54617168.095op/s 54852253.433op/s ± 78670.226op/s 54893441.210op/s ± 54170.467op/s 54924956.306op/s 54940128.501op/s 54946678.704op/s 54951474.383op/s 0.11% -0.493 -0.804 0.14% 5562.825op/s 1 200
normalization/normalize_name/normalize_name/good execution_time 11.247µs 11.278µs ± 0.032µs 11.267µs ± 0.007µs 11.294µs 11.316µs 11.437µs 11.509µs 2.15% 3.991 22.636 0.28% 0.002µs 1 200
normalization/normalize_name/normalize_name/good throughput 86888958.783op/s 88671131.413op/s ± 248799.734op/s 88754607.823op/s ± 57518.597op/s 88801457.371op/s 88859171.290op/s 88901699.883op/s 88909724.299op/s 0.17% -3.918 21.939 0.28% 17592.798op/s 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... execution_time [192.636µs; 193.068µs] or [-0.112%; +0.112%] None None None
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput [5179861.609op/s; 5191451.295op/s] or [-0.112%; +0.112%] None None None
normalization/normalize_name/normalize_name/bad-name execution_time [18.227µs; 18.234µs] or [-0.020%; +0.020%] None None None
normalization/normalize_name/normalize_name/bad-name throughput [54841350.496op/s; 54863156.370op/s] or [-0.020%; +0.020%] None None None
normalization/normalize_name/normalize_name/good execution_time [11.273µs; 11.282µs] or [-0.039%; +0.039%] None None None
normalization/normalize_name/normalize_name/good throughput [88636650.163op/s; 88705612.663op/s] or [-0.039%; +0.039%] None None None

Group 9

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
benching string interning on wordpress profile execution_time 143.376µs 144.138µs ± 0.525µs 144.079µs ± 0.211µs 144.305µs 144.768µs 145.429µs 149.585µs 3.82% 5.827 56.570 0.36% 0.037µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
benching string interning on wordpress profile execution_time [144.065µs; 144.210µs] or [-0.050%; +0.050%] None None None

Group 10

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
sql/obfuscate_sql_string execution_time 73.418µs 73.581µs ± 0.124µs 73.566µs ± 0.024µs 73.590µs 73.655µs 73.863µs 74.966µs 1.90% 8.365 83.344 0.17% 0.009µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
sql/obfuscate_sql_string execution_time [73.564µs; 73.599µs] or [-0.023%; +0.023%] None None None

Group 11

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
redis/obfuscate_redis_string execution_time 38.302µs 38.639µs ± 0.575µs 38.395µs ± 0.059µs 38.474µs 39.783µs 39.906µs 42.129µs 9.73% 2.298 6.333 1.49% 0.041µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
redis/obfuscate_redis_string execution_time [38.560µs; 38.719µs] or [-0.206%; +0.206%] None None None

Group 12

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 1955f2e 1729577834 ban/use-array-in-is-card-number
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
concentrator/add_spans_to_concentrator execution_time 9.075ms 9.115ms ± 0.017ms 9.114ms ± 0.012ms 9.126ms 9.147ms 9.156ms 9.193ms 0.87% 0.663 1.561 0.19% 0.001ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
concentrator/add_spans_to_concentrator execution_time [9.113ms; 9.118ms] or [-0.026%; +0.026%] None None None

Baseline

Omitted due to size.

@bantonsson bantonsson force-pushed the ban/use-array-in-is-card-number branch from 60e0f3b to 45b1728 Compare October 16, 2024 05:16
@bantonsson bantonsson changed the base branch from main to ban/stabilize-credit-cards-bench October 21, 2024 11:55
@bantonsson bantonsson force-pushed the ban/use-array-in-is-card-number branch from 45b1728 to 850a88a Compare October 21, 2024 11:55
@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.80%. Comparing base (6e2d784) to head (1955f2e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #678      +/-   ##
==========================================
+ Coverage   71.75%   71.80%   +0.05%     
==========================================
  Files         271      271              
  Lines       40992    40982      -10     
==========================================
+ Hits        29414    29429      +15     
+ Misses      11578    11553      -25     
Components Coverage Δ
crashtracker 20.28% <ø> (ø)
crashtracker-ffi 9.07% <ø> (ø)
datadog-alloc 98.73% <ø> (ø)
data-pipeline 91.92% <ø> (ø)
data-pipeline-ffi 0.00% <ø> (ø)
ddcommon 82.73% <ø> (ø)
ddcommon-ffi 69.12% <ø> (ø)
ddtelemetry 59.10% <ø> (ø)
ddtelemetry-ffi 22.13% <ø> (ø)
dogstatsd 88.86% <ø> (ø)
dogstatsd-client 79.77% <ø> (ø)
ipc 82.65% <ø> (ø)
profiling 84.30% <ø> (ø)
profiling-ffi 77.46% <ø> (ø)
serverless 0.00% <ø> (ø)
sidecar 36.09% <ø> (ø)
sidecar-ffi 0.00% <ø> (ø)
spawn-worker 50.36% <ø> (ø)
tinybytes 94.77% <ø> (ø)
trace-mini-agent 72.45% <ø> (ø)
trace-normalization 98.25% <ø> (ø)
trace-obfuscation 95.77% <91.66%> (+0.03%) ⬆️
trace-protobuf 77.67% <ø> (ø)
trace-utils 93.49% <ø> (+0.41%) ⬆️

@bantonsson bantonsson changed the title [WIP] Optimize is_card_number to use array Optimize is_card_number to use array Oct 21, 2024
@bantonsson bantonsson marked this pull request as ready for review October 21, 2024 12:36
@bantonsson bantonsson requested review from a team as code owners October 21, 2024 12:36
Base automatically changed from ban/stabilize-credit-cards-bench to main October 21, 2024 12:44
@bantonsson bantonsson force-pushed the ban/use-array-in-is-card-number branch from 850a88a to c6a567f Compare October 21, 2024 12:45
Copy link
Contributor

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me.

@@ -11,19 +11,29 @@ pub fn is_card_number<T: AsRef<str>>(s: T, validate_luhn: bool) -> bool {
return false;
}

let mut num_s = Vec::with_capacity(s.len());
let mut num_s = [0; 17];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a debug assert that s.len() <= num_s.len()?

Copy link
Contributor Author

@bantonsson bantonsson Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, s.len() can be longer than 17 but we stop after 17 digits in the loop below.

@bantonsson bantonsson force-pushed the ban/use-array-in-is-card-number branch from c6a567f to 1955f2e Compare October 22, 2024 06:17
@bantonsson bantonsson merged commit 7224cd1 into main Oct 22, 2024
30 checks passed
@bantonsson bantonsson deleted the ban/use-array-in-is-card-number branch October 22, 2024 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants