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

ekump/APMSP-1805 lazily init cadence client #890

Merged
merged 8 commits into from
Feb 21, 2025

Conversation

ekump
Copy link
Contributor

@ekump ekump commented Feb 19, 2025

What does this PR do?

Wait until send is called on dogstatsd client to initialize the cadence client.

Motivation

After this PR PHP customers in serverless environments started to experience an issue running out of file descriptors / threads. It is believed to be related to the creation of a new cadence client when initializing a new dogstatsd_client. This PR should re-establish previous behavior where the cadence client is lazily initialized when sending stats.

Additional Notes

We couldn't simply revert to using the previous code in the sidecar that lazily initialized the cadence client because the dogstatsd client is used in the Data Pipeline Trace Exporter inside async code and you can't just make the send method &mut self to allow us to set the client. So we have to use interior mutability via Arc and Mutex.

How to test the change?

Unit tests added and existing ones continue to work. PHP team manually verified this resolves the thread count issue.

@ekump ekump force-pushed the ekump/APMSP-1805-lazily-init-cadence-client branch from 7dbf470 to 0d252c6 Compare February 19, 2025 20:35
use std::thread;

#[tokio::test]
async fn test_thread_safety() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how useful this test is? It is just checking that we don't set a client until after we send. I couldn't think of a better way to unit test this.

@ekump ekump force-pushed the ekump/APMSP-1805-lazily-init-cadence-client branch from 0d252c6 to 6714915 Compare February 19, 2025 20:46
@ekump ekump marked this pull request as ready for review February 19, 2025 20:46
@ekump ekump requested review from a team as code owners February 19, 2025 20:46
@ekump ekump force-pushed the ekump/APMSP-1805-lazily-init-cadence-client branch from 6714915 to 0f7acb1 Compare February 19, 2025 20:55
@pr-commenter
Copy link

pr-commenter bot commented Feb 19, 2025

Benchmarks

Comparison

Benchmark execution time: 2025-02-20 23:14:59

Comparing candidate commit 13124e6 in PR branch ekump/APMSP-1805-lazily-init-cadence-client with baseline commit 2bf6b4c in branch main.

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

scenario:benching deserializing traces from msgpack to their internal representation

  • 🟥 execution_time [+3.443ms; +3.518ms] or [+6.422%; +6.562%]

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 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 244.692ns 254.235ns ± 11.014ns 248.552ns ± 3.035ns 257.087ns 279.577ns 284.700ns 285.276ns 14.77% 1.305 0.500 4.32% 0.779ns 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 [252.708ns; 255.761ns] or [-0.600%; +0.600%] None None None

Group 2

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
ip_address/quantize_peer_ip_address_benchmark execution_time 4.995µs 5.092µs ± 0.054µs 5.114µs ± 0.039µs 5.139µs 5.153µs 5.158µs 5.177µs 1.24% -0.295 -1.556 1.05% 0.004µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
ip_address/quantize_peer_ip_address_benchmark execution_time [5.085µs; 5.100µs] or [-0.146%; +0.146%] None None None

Group 3

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 503.954µs 505.789µs ± 0.470µs 505.778µs ± 0.239µs 506.021µs 506.322µs 507.168µs 509.386µs 0.71% 2.093 17.240 0.09% 0.033µs 1 200
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput 1963146.505op/s 1977109.005op/s ± 1835.458op/s 1977152.357op/s ± 931.997op/s 1978036.216op/s 1979333.820op/s 1980785.699op/s 1984307.217op/s 0.36% -2.052 16.928 0.09% 129.786op/s 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time 452.498µs 453.480µs ± 0.459µs 453.441µs ± 0.242µs 453.691µs 454.081µs 454.591µs 457.127µs 0.81% 2.816 19.435 0.10% 0.032µs 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput 2187577.556op/s 2205170.889op/s ± 2224.187op/s 2205358.094op/s ± 1175.271op/s 2206446.254op/s 2207873.059op/s 2208754.553op/s 2209955.496op/s 0.21% -2.775 19.038 0.10% 157.274op/s 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time 175.343µs 176.248µs ± 0.304µs 176.272µs ± 0.197µs 176.447µs 176.710µs 176.876µs 176.971µs 0.40% -0.358 0.058 0.17% 0.022µs 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput 5650658.901op/s 5673839.269op/s ± 9795.664op/s 5673047.207op/s ± 6329.511op/s 5679762.849op/s 5690366.801op/s 5698863.620op/s 5703108.417op/s 0.53% 0.368 0.068 0.17% 692.658op/s 1 200
normalization/normalize_service/normalize_service/[empty string] execution_time 37.609µs 37.714µs ± 0.042µs 37.711µs ± 0.028µs 37.739µs 37.791µs 37.826µs 37.841µs 0.34% 0.403 0.133 0.11% 0.003µs 1 200
normalization/normalize_service/normalize_service/[empty string] throughput 26426614.674op/s 26515262.139op/s ± 29689.641op/s 26517335.015op/s ± 19562.111op/s 26536863.348op/s 26558050.828op/s 26576326.155op/s 26589240.447op/s 0.27% -0.396 0.126 0.11% 2099.375op/s 1 200
normalization/normalize_service/normalize_service/test_ASCII execution_time 48.220µs 48.318µs ± 0.103µs 48.307µs ± 0.022µs 48.335µs 48.383µs 48.431µs 49.666µs 2.81% 11.245 144.485 0.21% 0.007µs 1 200
normalization/normalize_service/normalize_service/test_ASCII throughput 20134595.193op/s 20696210.898op/s ± 43131.548op/s 20700992.048op/s ± 9375.927op/s 20709762.388op/s 20722446.195op/s 20737802.613op/s 20738214.449op/s 0.18% -11.117 142.250 0.21% 3049.861op/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 [505.724µs; 505.855µs] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput [1976854.628op/s; 1977363.382op/s] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time [453.416µs; 453.544µs] or [-0.014%; +0.014%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput [2204862.638op/s; 2205479.140op/s] or [-0.014%; +0.014%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time [176.206µs; 176.290µs] or [-0.024%; +0.024%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput [5672481.684op/s; 5675196.854op/s] or [-0.024%; +0.024%] None None None
normalization/normalize_service/normalize_service/[empty string] execution_time [37.708µs; 37.720µs] or [-0.016%; +0.016%] None None None
normalization/normalize_service/normalize_service/[empty string] throughput [26511147.441op/s; 26519376.838op/s] or [-0.016%; +0.016%] None None None
normalization/normalize_service/normalize_service/test_ASCII execution_time [48.304µs; 48.333µs] or [-0.030%; +0.030%] None None None
normalization/normalize_service/normalize_service/test_ASCII throughput [20690233.280op/s; 20702188.516op/s] or [-0.029%; +0.029%] None None None

Group 4

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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.197µs 3.188µs ± 1.537µs 2.988µs ± 0.025µs 3.011µs 3.592µs 13.989µs 17.357µs 480.93% 7.679 60.440 48.10% 0.109µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
write only interface execution_time [2.975µs; 3.401µs] or [-6.683%; +6.683%] None None None

Group 5

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 149.690µs 150.992µs ± 0.412µs 150.919µs ± 0.153µs 151.102µs 151.635µs 152.446µs 154.043µs 2.07% 2.990 18.129 0.27% 0.029µ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 [150.935µs; 151.049µs] or [-0.038%; +0.038%] None None None

Group 6

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 208.596µs 209.067µs ± 0.162µs 209.060µs ± 0.099µs 209.159µs 209.340µs 209.442µs 209.499µs 0.21% 0.105 -0.126 0.08% 0.011µs 1 200
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput 4773287.411op/s 4783158.413op/s ± 3713.866op/s 4783317.066op/s ± 2269.775op/s 4785515.839op/s 4789022.443op/s 4790657.095op/s 4793944.928op/s 0.22% -0.101 -0.127 0.08% 262.610op/s 1 200
normalization/normalize_name/normalize_name/bad-name execution_time 18.230µs 18.320µs ± 0.041µs 18.319µs ± 0.020µs 18.340µs 18.369µs 18.398µs 18.631µs 1.70% 2.716 19.148 0.22% 0.003µs 1 200
normalization/normalize_name/normalize_name/bad-name throughput 53675025.236op/s 54585049.198op/s ± 121245.138op/s 54586905.579op/s ± 58568.580op/s 54640606.006op/s 54744091.963op/s 54850909.076op/s 54855722.535op/s 0.49% -2.625 18.393 0.22% 8573.326op/s 1 200
normalization/normalize_name/normalize_name/good execution_time 10.667µs 10.734µs ± 0.024µs 10.735µs ± 0.017µs 10.751µs 10.767µs 10.781µs 10.818µs 0.77% -0.197 0.446 0.22% 0.002µs 1 200
normalization/normalize_name/normalize_name/good throughput 92437345.256op/s 93166562.007op/s ± 209996.169op/s 93153504.109op/s ± 144390.986op/s 93304420.926op/s 93577566.801op/s 93675872.666op/s 93743352.334op/s 0.63% 0.213 0.439 0.22% 14848.972op/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 [209.045µs; 209.090µs] or [-0.011%; +0.011%] None None None
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput [4782643.707op/s; 4783673.119op/s] or [-0.011%; +0.011%] None None None
normalization/normalize_name/normalize_name/bad-name execution_time [18.314µs; 18.326µs] or [-0.031%; +0.031%] None None None
normalization/normalize_name/normalize_name/bad-name throughput [54568245.788op/s; 54601852.608op/s] or [-0.031%; +0.031%] None None None
normalization/normalize_name/normalize_name/good execution_time [10.730µs; 10.737µs] or [-0.031%; +0.031%] None None None
normalization/normalize_name/normalize_name/good throughput [93137458.558op/s; 93195665.456op/s] or [-0.031%; +0.031%] None None None

Group 7

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 32.875µs 33.330µs ± 0.792µs 32.976µs ± 0.037µs 33.037µs 34.966µs 35.026µs 37.308µs 13.14% 1.986 3.169 2.37% 0.056µ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 [33.221µs; 33.440µs] or [-0.329%; +0.329%] None None None

Group 8

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 5.936ms 5.951ms ± 0.009ms 5.950ms ± 0.003ms 5.953ms 5.958ms 5.994ms 6.025ms 1.27% 5.054 32.842 0.15% 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 [5.950ms; 5.952ms] or [-0.021%; +0.021%] None None None

Group 9

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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.353µs 2.410µs ± 0.019µs 2.411µs ± 0.013µs 2.421µs 2.450µs 2.462µs 2.463µs 2.14% 0.154 0.974 0.80% 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.407µs; 2.413µs] or [-0.112%; +0.112%] None None None

Group 10

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 65.488µs 65.690µs ± 0.195µs 65.662µs ± 0.051µs 65.721µs 65.874µs 66.055µs 67.915µs 3.43% 8.016 84.491 0.30% 0.014µ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 [65.663µs; 65.717µs] or [-0.041%; +0.041%] None None None

Group 11

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 56.807ms 57.096ms ± 0.213ms 57.052ms ± 0.089ms 57.148ms 57.449ms 57.806ms 58.814ms 3.09% 3.522 21.341 0.37% 0.015ms 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 [57.066ms; 57.125ms] or [-0.052%; +0.052%] None None None

Group 12

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 3.894µs 3.914µs ± 0.003µs 3.913µs ± 0.001µs 3.915µs 3.918µs 3.919µs 3.920µs 0.18% -1.644 11.725 0.07% 0.000µs 1 200
credit_card/is_card_number/ throughput 255084168.794op/s 255514471.450op/s ± 179886.526op/s 255534544.827op/s ± 76983.253op/s 255601361.079op/s 255798171.966op/s 255935356.449op/s 256796749.894op/s 0.49% 1.668 11.910 0.07% 12719.898op/s 1 200
credit_card/is_card_number/ 3782-8224-6310-005 execution_time 81.406µs 82.736µs ± 0.633µs 82.724µs ± 0.444µs 83.133µs 83.752µs 84.030µs 86.265µs 4.28% 0.946 3.498 0.76% 0.045µs 1 200
credit_card/is_card_number/ 3782-8224-6310-005 throughput 11592178.054op/s 12087317.138op/s ± 91867.262op/s 12088362.200op/s ± 64511.604op/s 12162118.044op/s 12212421.810op/s 12248211.049op/s 12284147.640op/s 1.62% -0.846 2.917 0.76% 6495.996op/s 1 200
credit_card/is_card_number/ 378282246310005 execution_time 78.067µs 79.571µs ± 0.501µs 79.596µs ± 0.278µs 79.840µs 80.182µs 80.346µs 83.690µs 5.14% 2.470 21.556 0.63% 0.035µs 1 200
credit_card/is_card_number/ 378282246310005 throughput 11948882.493op/s 12567842.736op/s ± 78048.128op/s 12563443.548op/s ± 43823.196op/s 12614232.992op/s 12682545.838op/s 12745378.791op/s 12809447.765op/s 1.96% -2.157 18.670 0.62% 5518.836op/s 1 200
credit_card/is_card_number/37828224631 execution_time 3.898µs 3.914µs ± 0.003µs 3.914µs ± 0.001µs 3.915µs 3.918µs 3.920µs 3.922µs 0.22% -0.794 3.701 0.07% 0.000µs 1 200
credit_card/is_card_number/37828224631 throughput 254965238.542op/s 255514441.721op/s ± 191348.431op/s 255518221.393op/s ± 90181.370op/s 255593552.655op/s 255841227.580op/s 255952059.756op/s 256551343.693op/s 0.40% 0.805 3.752 0.07% 13530.377op/s 1 200
credit_card/is_card_number/378282246310005 execution_time 74.970µs 76.383µs ± 0.427µs 76.443µs ± 0.275µs 76.685µs 76.962µs 77.283µs 77.294µs 1.11% -0.498 0.040 0.56% 0.030µs 1 200
credit_card/is_card_number/378282246310005 throughput 12937645.254op/s 13092358.257op/s ± 73448.914op/s 13081562.801op/s ± 46843.018op/s 13142055.045op/s 13232824.105op/s 13276621.737op/s 13338710.585op/s 1.97% 0.529 0.086 0.56% 5193.623op/s 1 200
credit_card/is_card_number/37828224631000521389798 execution_time 51.352µs 51.432µs ± 0.027µs 51.433µs ± 0.016µs 51.449µs 51.475µs 51.489µs 51.514µs 0.16% -0.154 0.642 0.05% 0.002µs 1 200
credit_card/is_card_number/37828224631000521389798 throughput 19412299.115op/s 19442993.368op/s ± 10217.115op/s 19442843.872op/s ± 5996.925op/s 19448574.566op/s 19463727.203op/s 19470003.092op/s 19473587.973op/s 0.16% 0.158 0.644 0.05% 722.459op/s 1 200
credit_card/is_card_number/x371413321323331 execution_time 6.028µs 6.038µs ± 0.003µs 6.037µs ± 0.002µs 6.040µs 6.044µs 6.045µs 6.048µs 0.18% 0.322 0.752 0.05% 0.000µs 1 200
credit_card/is_card_number/x371413321323331 throughput 165331542.125op/s 165623368.677op/s ± 88885.078op/s 165634673.685op/s ± 48120.159op/s 165675736.796op/s 165757384.378op/s 165833818.176op/s 165892717.570op/s 0.16% -0.317 0.750 0.05% 6285.124op/s 1 200
credit_card/is_card_number_no_luhn/ execution_time 3.892µs 3.914µs ± 0.003µs 3.913µs ± 0.001µs 3.915µs 3.917µs 3.919µs 3.920µs 0.17% -2.785 22.782 0.07% 0.000µs 1 200
credit_card/is_card_number_no_luhn/ throughput 255091831.562op/s 255522497.645op/s ± 170858.590op/s 255534136.083op/s ± 89191.165op/s 255605738.349op/s 255726158.667op/s 255887896.466op/s 256951100.275op/s 0.55% 2.819 23.126 0.07% 12081.527op/s 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time 65.874µs 66.593µs ± 0.417µs 66.565µs ± 0.286µs 66.876µs 67.341µs 67.672µs 67.787µs 1.84% 0.407 -0.113 0.62% 0.029µs 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput 14752115.610op/s 15017202.504op/s ± 93812.435op/s 15022898.019op/s ± 64454.981op/s 15079645.498op/s 15168062.357op/s 15175339.720op/s 15180459.471op/s 1.05% -0.375 -0.157 0.62% 6633.541op/s 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time 59.418µs 59.684µs ± 0.091µs 59.684µs ± 0.059µs 59.744µs 59.822µs 59.915µs 59.934µs 0.42% -0.026 -0.158 0.15% 0.006µs 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 throughput 16685131.214op/s 16754889.012op/s ± 25660.719op/s 16754960.154op/s ± 16589.162op/s 16771169.104op/s 16799737.589op/s 16808652.153op/s 16829849.421op/s 0.45% 0.034 -0.159 0.15% 1814.487op/s 1 200
credit_card/is_card_number_no_luhn/37828224631 execution_time 3.895µs 3.914µs ± 0.003µs 3.914µs ± 0.001µs 3.915µs 3.919µs 3.920µs 3.921µs 0.19% -1.348 9.966 0.07% 0.000µs 1 200
credit_card/is_card_number_no_luhn/37828224631 throughput 255043039.386op/s 255503726.649op/s ± 177083.801op/s 255518295.110op/s ± 79421.193op/s 255584477.061op/s 255764112.257op/s 255883314.485op/s 256714542.170op/s 0.47% 1.369 10.118 0.07% 12521.716op/s 1 200
credit_card/is_card_number_no_luhn/378282246310005 execution_time 56.308µs 56.828µs ± 0.178µs 56.828µs ± 0.121µs 56.953µs 57.126µs 57.216µs 57.227µs 0.70% -0.137 -0.243 0.31% 0.013µs 1 200
credit_card/is_card_number_no_luhn/378282246310005 throughput 17474326.392op/s 17597145.302op/s ± 55249.423op/s 17596814.978op/s ± 37453.685op/s 17632841.608op/s 17695232.557op/s 17717210.551op/s 17759589.447op/s 0.93% 0.154 -0.235 0.31% 3906.724op/s 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time 51.350µs 51.439µs ± 0.031µs 51.436µs ± 0.019µs 51.457µs 51.497µs 51.524µs 51.559µs 0.24% 0.631 1.428 0.06% 0.002µs 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput 19395406.392op/s 19440593.848op/s ± 11565.076op/s 19441566.428op/s ± 7183.453op/s 19447797.254op/s 19456741.632op/s 19464863.278op/s 19474179.186op/s 0.17% -0.626 1.418 0.06% 817.774op/s 1 200
credit_card/is_card_number_no_luhn/x371413321323331 execution_time 6.027µs 6.039µs ± 0.009µs 6.038µs ± 0.002µs 6.041µs 6.046µs 6.102µs 6.110µs 1.20% 5.708 39.488 0.15% 0.001µs 1 200
credit_card/is_card_number_no_luhn/x371413321323331 throughput 163660087.880op/s 165582227.936op/s ± 247444.142op/s 165619948.924op/s ± 67691.554op/s 165666332.807op/s 165814293.418op/s 165870712.294op/s 165928887.648op/s 0.19% -5.668 39.111 0.15% 17496.943op/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 [3.913µs; 3.914µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/ throughput [255489540.908op/s; 255539401.992op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 execution_time [82.648µs; 82.824µs] or [-0.106%; +0.106%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 throughput [12074585.219op/s; 12100049.057op/s] or [-0.105%; +0.105%] None None None
credit_card/is_card_number/ 378282246310005 execution_time [79.502µs; 79.641µs] or [-0.087%; +0.087%] None None None
credit_card/is_card_number/ 378282246310005 throughput [12557026.016op/s; 12578659.456op/s] or [-0.086%; +0.086%] None None None
credit_card/is_card_number/37828224631 execution_time [3.913µs; 3.914µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/37828224631 throughput [255487922.668op/s; 255540960.773op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/378282246310005 execution_time [76.324µs; 76.442µs] or [-0.078%; +0.078%] None None None
credit_card/is_card_number/378282246310005 throughput [13082178.944op/s; 13102537.570op/s] or [-0.078%; +0.078%] None None None
credit_card/is_card_number/37828224631000521389798 execution_time [51.429µs; 51.436µs] or [-0.007%; +0.007%] None None None
credit_card/is_card_number/37828224631000521389798 throughput [19441577.374op/s; 19444409.362op/s] or [-0.007%; +0.007%] None None None
credit_card/is_card_number/x371413321323331 execution_time [6.037µs; 6.038µs] or [-0.007%; +0.007%] None None None
credit_card/is_card_number/x371413321323331 throughput [165611050.060op/s; 165635687.294op/s] or [-0.007%; +0.007%] None None None
credit_card/is_card_number_no_luhn/ execution_time [3.913µs; 3.914µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/ throughput [255498818.287op/s; 255546177.002op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time [66.535µs; 66.651µs] or [-0.087%; +0.087%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput [15004201.003op/s; 15030204.005op/s] or [-0.087%; +0.087%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time [59.672µs; 59.697µs] or [-0.021%; +0.021%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 throughput [16751332.683op/s; 16758445.341op/s] or [-0.021%; +0.021%] None None None
credit_card/is_card_number_no_luhn/37828224631 execution_time [3.913µs; 3.914µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/37828224631 throughput [255479184.537op/s; 255528268.761op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/378282246310005 execution_time [56.803µs; 56.853µs] or [-0.043%; +0.043%] None None None
credit_card/is_card_number_no_luhn/378282246310005 throughput [17589488.264op/s; 17604802.341op/s] or [-0.044%; +0.044%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time [51.435µs; 51.443µs] or [-0.008%; +0.008%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput [19438991.040op/s; 19442196.656op/s] or [-0.008%; +0.008%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 execution_time [6.038µs; 6.041µs] or [-0.021%; +0.021%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 throughput [165547934.558op/s; 165616521.314op/s] or [-0.021%; +0.021%] None None None

Group 13

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 13124e6 1740092612 ekump/APMSP-1805-lazily-init-cadence-client
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 17.775µs 25.228µs ± 10.131µs 17.936µs ± 0.089µs 34.028µs 41.667µs 47.975µs 89.415µs 398.51% 1.792 6.657 40.06% 0.716µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
two way interface execution_time [23.824µs; 26.632µs] or [-5.566%; +5.566%] None None None

Baseline

Omitted due to size.

@codecov-commenter
Copy link

codecov-commenter commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 70.90909% with 32 lines in your changes missing coverage. Please review.

Project coverage is 71.79%. Comparing base (2bf6b4c) to head (13124e6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #890      +/-   ##
==========================================
+ Coverage   71.75%   71.79%   +0.03%     
==========================================
  Files         328      328              
  Lines       48514    48577      +63     
==========================================
+ Hits        34813    34874      +61     
- Misses      13701    13703       +2     
Components Coverage Δ
crashtracker 42.90% <0.00%> (ø)
crashtracker-ffi 6.25% <0.00%> (ø)
datadog-alloc 98.73% <ø> (ø)
data-pipeline 92.07% <100.00%> (ø)
data-pipeline-ffi 90.39% <ø> (ø)
ddcommon 80.08% <ø> (ø)
ddcommon-ffi 61.05% <ø> (ø)
ddtelemetry 61.74% <ø> (ø)
ddtelemetry-ffi 22.46% <ø> (ø)
dogstatsd 90.16% <73.00%> (+0.01%) ⬆️
dogstatsd-client 82.57% <73.00%> (+2.79%) ⬆️
ipc 82.68% <ø> (ø)
profiling 80.04% <ø> (ø)
profiling-ffi 70.68% <ø> (ø)
serverless 0.00% <ø> (ø)
sidecar 40.86% <0.00%> (+0.34%) ⬆️
sidecar-ffi 4.70% <ø> (+2.64%) ⬆️
spawn-worker 54.37% <ø> (ø)
tinybytes 92.85% <ø> (ø)
trace-mini-agent 72.48% <ø> (ø)
trace-normalization 98.23% <100.00%> (ø)
trace-obfuscation 95.96% <ø> (ø)
trace-protobuf 78.13% <ø> (ø)
trace-utils 93.30% <ø> (ø)

/// Set the destination for dogstatsd metrics, if an API Key is provided the client is disabled
/// as dogstatsd is not allowed in agentless mode. Returns an error if the provided endpoint
/// is invalid.
pub fn set_endpoint(&mut self, endpoint: Endpoint) -> anyhow::Result<()> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function wasn't used anywhere else in libdatadog. I can leave it in as it is technically a breaking API change if we think the crate is being used outside of libdatadog.

Copy link
Contributor

@bantonsson bantonsson left a comment

Choose a reason for hiding this comment

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

Looks good in general, but I have a few questions.

@ekump ekump force-pushed the ekump/APMSP-1805-lazily-init-cadence-client branch from 4933211 to c5bb7c9 Compare February 20, 2025 22:03
APMSP-1805. Sidecar potentially has 100s of sessions, each of which
creates dogstatsd clients. Defer initalizing new cadence clients until
we are actually ready to send. Cadence creates a new OS thread every
time a client is initialized.
@ekump ekump force-pushed the ekump/APMSP-1805-lazily-init-cadence-client branch from c5bb7c9 to 61d2838 Compare February 20, 2025 22:06
@ekump ekump enabled auto-merge (squash) February 20, 2025 22:09
@ekump ekump requested a review from a team as a code owner February 20, 2025 22:18
@ekump ekump requested a review from a team as a code owner February 20, 2025 22:31
@ekump ekump force-pushed the ekump/APMSP-1805-lazily-init-cadence-client branch from 9d3ee1a to b37dc4e Compare February 20, 2025 22:41
@ekump ekump force-pushed the ekump/APMSP-1805-lazily-init-cadence-client branch from b37dc4e to 13124e6 Compare February 20, 2025 23:03
Copy link
Contributor

@bantonsson bantonsson left a comment

Choose a reason for hiding this comment

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

👍🏼

DogStatsDAction::Set(metric, value, tags) => {
do_send(client.set_with_tags(metric.as_ref(), value), tags)
let client_opt = match self.get_or_init_client() {
Ok(guard) => guard,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: variable name guard is a bit confusing since it's the client option now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes, forgot to update this variable. I'll make a note to update it in another PR.

@ekump ekump merged commit 1f16a44 into main Feb 21, 2025
31 checks passed
@ekump ekump deleted the ekump/APMSP-1805-lazily-init-cadence-client branch February 21, 2025 07:02
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.

3 participants