Skip to content

ekump/APMSP-2151 create ddsketch ffi crate #1135

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ekump
Copy link
Contributor

@ekump ekump commented Jul 9, 2025

What does this PR do?

Initial creation of the ddsketch-ffi crate. Exposes public API of ddsketch for FFI.

Motivation

DSM would like to use the libdatadog implementation of ddsketch for dd-trace-rb.

Additional Notes

Also added a helper method for Cstring to unwrap_or_default to an empty string (which also requires an unwrap, even though it's safe) to reduce the need to add clippy allow annotations all over the codebase for something that shouldn't ever panic.

How to test the change?

Describe here in detail how the change can be validated.

@github-actions github-actions bot added the common label Jul 9, 2025
@pr-commenter
Copy link

pr-commenter bot commented Jul 9, 2025

Benchmarks

Comparison

Benchmark execution time: 2025-07-09 23:49:39

Comparing candidate commit 26d59f7 in PR branch ekump/APMSP-2151-create-ddsketch-ffi-crate with baseline commit b708db7 in branch main.

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

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 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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.614ns 255.842ns ± 14.311ns 248.982ns ± 3.449ns 262.548ns 288.311ns 300.406ns 305.843ns 22.84% 1.468 1.209 5.58% 1.012ns 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 [253.859ns; 257.825ns] or [-0.775%; +0.775%] None None None

Group 2

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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 151.485µs 152.177µs ± 0.283µs 152.156µs ± 0.159µs 152.318µs 152.618µs 153.120µs 153.242µs 0.71% 0.838 2.097 0.19% 0.020µ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 [152.138µs; 152.217µs] or [-0.026%; +0.026%] None None None

Group 3

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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 86.354µs 86.678µs ± 0.149µs 86.671µs ± 0.056µs 86.722µs 86.848µs 87.204µs 87.954µs 1.48% 3.701 27.407 0.17% 0.011µ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 [86.658µs; 86.699µs] or [-0.024%; +0.024%] None None None

Group 4

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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.341µs 2.395µs ± 0.021µs 2.392µs ± 0.011µs 2.405µs 2.442µs 2.450µs 2.451µs 2.45% 0.456 0.815 0.88% 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.392µs; 2.398µs] or [-0.122%; +0.122%] None None None

Group 5

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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 535.244µs 536.036µs ± 0.561µs 535.972µs ± 0.231µs 536.210µs 536.732µs 537.342µs 541.876µs 1.10% 5.827 56.887 0.10% 0.040µs 1 200
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput 1845441.656op/s 1865546.909op/s ± 1942.274op/s 1865768.288op/s ± 804.949op/s 1866548.840op/s 1867470.168op/s 1868093.845op/s 1868307.407op/s 0.14% -5.750 55.801 0.10% 137.340op/s 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time 381.053µs 382.769µs ± 0.658µs 382.760µs ± 0.534µs 383.232µs 383.800µs 384.249µs 385.251µs 0.65% 0.397 0.085 0.17% 0.047µs 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput 2595709.743op/s 2612551.677op/s ± 4491.216op/s 2612605.869op/s ± 3645.670op/s 2616358.194op/s 2618932.053op/s 2620381.774op/s 2624305.058op/s 0.45% -0.387 0.064 0.17% 317.577op/s 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time 195.306µs 195.814µs ± 0.586µs 195.745µs ± 0.144µs 195.897µs 196.143µs 196.457µs 201.396µs 2.89% 8.020 71.910 0.30% 0.041µs 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput 4965352.294op/s 5106936.508op/s ± 14933.722op/s 5108694.878op/s ± 3747.230op/s 5112272.569op/s 5116603.833op/s 5119211.193op/s 5120173.849op/s 0.22% -7.934 70.847 0.29% 1055.974op/s 1 200
normalization/normalize_service/normalize_service/[empty string] execution_time 38.024µs 38.137µs ± 0.038µs 38.133µs ± 0.024µs 38.162µs 38.205µs 38.224µs 38.254µs 0.32% 0.346 0.245 0.10% 0.003µs 1 200
normalization/normalize_service/normalize_service/[empty string] throughput 26141134.429op/s 26221094.568op/s ± 26209.256op/s 26224291.999op/s ± 16187.833op/s 26237701.080op/s 26260629.605op/s 26277054.650op/s 26299323.559op/s 0.29% -0.340 0.242 0.10% 1853.274op/s 1 200
normalization/normalize_service/normalize_service/test_ASCII execution_time 45.895µs 46.018µs ± 0.067µs 46.014µs ± 0.041µs 46.052µs 46.123µs 46.240µs 46.355µs 0.74% 1.264 3.806 0.14% 0.005µs 1 200
normalization/normalize_service/normalize_service/test_ASCII throughput 21572495.931op/s 21730473.691op/s ± 31523.544op/s 21732594.909op/s ± 19495.500op/s 21752055.570op/s 21775199.691op/s 21785146.243op/s 21788781.489op/s 0.26% -1.246 3.719 0.14% 2229.051op/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 [535.959µs; 536.114µs] or [-0.015%; +0.015%] None None None
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput [1865277.729op/s; 1865816.090op/s] or [-0.014%; +0.014%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time [382.677µs; 382.860µs] or [-0.024%; +0.024%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput [2611929.237op/s; 2613174.116op/s] or [-0.024%; +0.024%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time [195.733µs; 195.895µs] or [-0.041%; +0.041%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput [5104866.838op/s; 5109006.179op/s] or [-0.041%; +0.041%] None None None
normalization/normalize_service/normalize_service/[empty string] execution_time [38.132µs; 38.143µs] or [-0.014%; +0.014%] None None None
normalization/normalize_service/normalize_service/[empty string] throughput [26217462.217op/s; 26224726.919op/s] or [-0.014%; +0.014%] None None None
normalization/normalize_service/normalize_service/test_ASCII execution_time [46.009µs; 46.028µs] or [-0.020%; +0.020%] None None None
normalization/normalize_service/normalize_service/test_ASCII throughput [21726104.831op/s; 21734842.551op/s] or [-0.020%; +0.020%] None None None

Group 6

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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.893µs 3.913µs ± 0.003µs 3.913µs ± 0.002µs 3.915µs 3.917µs 3.919µs 3.919µs 0.16% -1.445 9.299 0.07% 0.000µs 1 200
credit_card/is_card_number/ throughput 255139360.514op/s 255558474.714op/s ± 190987.666op/s 255551493.626op/s ± 108146.015op/s 255660605.995op/s 255830019.446op/s 255947501.431op/s 256857982.468op/s 0.51% 1.466 9.458 0.07% 13504.867op/s 1 200
credit_card/is_card_number/ 3782-8224-6310-005 execution_time 79.363µs 81.348µs ± 0.615µs 81.282µs ± 0.404µs 81.787µs 82.494µs 82.809µs 83.120µs 2.26% 0.270 0.018 0.75% 0.043µs 1 200
credit_card/is_card_number/ 3782-8224-6310-005 throughput 12030822.380op/s 12293525.206op/s ± 92762.787op/s 12302783.525op/s ± 61457.372op/s 12363105.312op/s 12434814.781op/s 12457652.344op/s 12600349.491op/s 2.42% -0.226 0.027 0.75% 6559.320op/s 1 200
credit_card/is_card_number/ 378282246310005 execution_time 75.270µs 75.678µs ± 0.158µs 75.642µs ± 0.077µs 75.750µs 75.951µs 76.227µs 76.374µs 0.97% 0.963 2.887 0.21% 0.011µs 1 200
credit_card/is_card_number/ 378282246310005 throughput 13093423.744op/s 13213974.574op/s ± 27461.869op/s 13220149.635op/s ± 13520.563op/s 13229319.394op/s 13248569.319op/s 13280039.602op/s 13285456.411op/s 0.49% -0.938 2.818 0.21% 1941.847op/s 1 200
credit_card/is_card_number/37828224631 execution_time 3.893µs 3.913µs ± 0.003µs 3.913µs ± 0.002µs 3.915µs 3.917µs 3.919µs 3.921µs 0.20% -1.060 7.613 0.08% 0.000µs 1 200
credit_card/is_card_number/37828224631 throughput 255068857.619op/s 255578513.338op/s ± 196692.221op/s 255582227.749op/s ± 131164.810op/s 255708010.062op/s 255824061.882op/s 255898032.834op/s 256862585.749op/s 0.50% 1.080 7.752 0.08% 13908.240op/s 1 200
credit_card/is_card_number/378282246310005 execution_time 72.435µs 72.811µs ± 0.100µs 72.815µs ± 0.058µs 72.868µs 72.958µs 73.069µs 73.091µs 0.38% -0.285 1.355 0.14% 0.007µs 1 200
credit_card/is_card_number/378282246310005 throughput 13681625.211op/s 13734246.601op/s ± 18909.865op/s 13733393.727op/s ± 10982.098op/s 13744606.488op/s 13766098.162op/s 13786290.101op/s 13805444.867op/s 0.52% 0.298 1.371 0.14% 1337.129op/s 1 200
credit_card/is_card_number/37828224631000521389798 execution_time 52.633µs 52.862µs ± 0.080µs 52.857µs ± 0.049µs 52.912µs 53.005µs 53.060µs 53.098µs 0.46% 0.260 0.269 0.15% 0.006µs 1 200
credit_card/is_card_number/37828224631000521389798 throughput 18832940.518op/s 18917282.271op/s ± 28461.047op/s 18919048.231op/s ± 17713.186op/s 18933367.327op/s 18958862.302op/s 18979952.703op/s 18999384.420op/s 0.42% -0.250 0.266 0.15% 2012.500op/s 1 200
credit_card/is_card_number/x371413321323331 execution_time 6.426µs 6.439µs ± 0.014µs 6.437µs ± 0.003µs 6.440µs 6.448µs 6.454µs 6.576µs 2.16% 8.089 72.610 0.22% 0.001µs 1 200
credit_card/is_card_number/x371413321323331 throughput 152067158.654op/s 155316322.125op/s ± 342805.542op/s 155346603.981op/s ± 70656.224op/s 155425447.765op/s 155536803.230op/s 155590813.080op/s 155607901.354op/s 0.17% -8.027 71.841 0.22% 24240.012op/s 1 200
credit_card/is_card_number_no_luhn/ execution_time 3.900µs 3.912µs ± 0.003µs 3.912µs ± 0.002µs 3.914µs 3.917µs 3.919µs 3.927µs 0.38% 0.539 3.866 0.07% 0.000µs 1 200
credit_card/is_card_number_no_luhn/ throughput 254669454.585op/s 255627748.677op/s ± 188999.415op/s 255642825.492op/s ± 115077.100op/s 255753177.480op/s 255879317.668op/s 255981985.662op/s 256425916.126op/s 0.31% -0.527 3.842 0.07% 13364.277op/s 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time 64.935µs 65.080µs ± 0.080µs 65.066µs ± 0.054µs 65.128µs 65.233µs 65.300µs 65.415µs 0.54% 1.020 1.567 0.12% 0.006µs 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput 15286949.948op/s 15365717.362op/s ± 18942.344op/s 15368950.111op/s ± 12778.048op/s 15379448.829op/s 15389438.613op/s 15394918.868op/s 15399898.361op/s 0.20% -1.011 1.534 0.12% 1339.426op/s 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time 58.158µs 58.337µs ± 0.102µs 58.311µs ± 0.055µs 58.383µs 58.527µs 58.659µs 58.843µs 0.91% 1.531 3.891 0.17% 0.007µs 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 throughput 16994295.944op/s 17141703.677op/s ± 29797.550op/s 17149369.915op/s ± 16070.046op/s 17160940.413op/s 17176137.193op/s 17188164.788op/s 17194490.885op/s 0.26% -1.512 3.797 0.17% 2107.005op/s 1 200
credit_card/is_card_number_no_luhn/37828224631 execution_time 3.891µs 3.913µs ± 0.004µs 3.913µs ± 0.002µs 3.915µs 3.919µs 3.921µs 3.926µs 0.33% -0.485 5.972 0.09% 0.000µs 1 200
credit_card/is_card_number_no_luhn/37828224631 throughput 254737195.297op/s 255563466.261op/s ± 238286.687op/s 255588793.363op/s ± 147943.219op/s 255732804.129op/s 255836902.164op/s 255884031.304op/s 257009592.378op/s 0.56% 0.506 6.089 0.09% 16849.413op/s 1 200
credit_card/is_card_number_no_luhn/378282246310005 execution_time 55.186µs 55.429µs ± 0.159µs 55.390µs ± 0.088µs 55.521µs 55.717µs 55.967µs 55.999µs 1.10% 1.270 1.809 0.29% 0.011µs 1 200
credit_card/is_card_number_no_luhn/378282246310005 throughput 17857375.412op/s 18041216.149op/s ± 51670.549op/s 18053772.415op/s ± 28711.257op/s 18075518.518op/s 18105642.718op/s 18114734.663op/s 18120626.709op/s 0.37% -1.251 1.745 0.29% 3653.660op/s 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time 52.670µs 52.852µs ± 0.067µs 52.850µs ± 0.046µs 52.897µs 52.962µs 53.010µs 53.037µs 0.35% 0.030 -0.065 0.13% 0.005µs 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput 18854681.315op/s 18920639.995op/s ± 24042.730op/s 18921360.932op/s ± 16533.770op/s 18937297.193op/s 18958575.897op/s 18979240.080op/s 18986204.624op/s 0.34% -0.023 -0.065 0.13% 1700.078op/s 1 200
credit_card/is_card_number_no_luhn/x371413321323331 execution_time 6.427µs 6.438µs ± 0.005µs 6.438µs ± 0.004µs 6.441µs 6.446µs 6.454µs 6.455µs 0.28% 0.504 0.354 0.08% 0.000µs 1 200
credit_card/is_card_number_no_luhn/x371413321323331 throughput 154910096.819op/s 155339899.631op/s ± 130110.708op/s 155338897.445op/s ± 90090.062op/s 155436496.489op/s 155534698.513op/s 155570429.895op/s 155601052.119op/s 0.17% -0.499 0.344 0.08% 9200.216op/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.913µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/ throughput [255532005.661op/s; 255584943.768op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 execution_time [81.263µs; 81.433µs] or [-0.105%; +0.105%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 throughput [12280669.176op/s; 12306381.236op/s] or [-0.105%; +0.105%] None None None
credit_card/is_card_number/ 378282246310005 execution_time [75.656µs; 75.700µs] or [-0.029%; +0.029%] None None None
credit_card/is_card_number/ 378282246310005 throughput [13210168.624op/s; 13217780.525op/s] or [-0.029%; +0.029%] None None None
credit_card/is_card_number/37828224631 execution_time [3.912µs; 3.913µs] or [-0.011%; +0.011%] None None None
credit_card/is_card_number/37828224631 throughput [255551253.688op/s; 255605772.988op/s] or [-0.011%; +0.011%] None None None
credit_card/is_card_number/378282246310005 execution_time [72.797µs; 72.825µs] or [-0.019%; +0.019%] None None None
credit_card/is_card_number/378282246310005 throughput [13731625.875op/s; 13736867.326op/s] or [-0.019%; +0.019%] None None None
credit_card/is_card_number/37828224631000521389798 execution_time [52.851µs; 52.873µs] or [-0.021%; +0.021%] None None None
credit_card/is_card_number/37828224631000521389798 throughput [18913337.844op/s; 18921226.698op/s] or [-0.021%; +0.021%] None None None
credit_card/is_card_number/x371413321323331 execution_time [6.437µs; 6.441µs] or [-0.031%; +0.031%] None None None
credit_card/is_card_number/x371413321323331 throughput [155268812.574op/s; 155363831.676op/s] or [-0.031%; +0.031%] None None None
credit_card/is_card_number_no_luhn/ execution_time [3.912µs; 3.912µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/ throughput [255601555.176op/s; 255653942.179op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time [65.069µs; 65.091µs] or [-0.017%; +0.017%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput [15363092.135op/s; 15368342.589op/s] or [-0.017%; +0.017%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time [58.323µs; 58.352µs] or [-0.024%; +0.024%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 throughput [17137574.023op/s; 17145833.330op/s] or [-0.024%; +0.024%] None None None
credit_card/is_card_number_no_luhn/37828224631 execution_time [3.912µs; 3.913µs] or [-0.013%; +0.013%] None None None
credit_card/is_card_number_no_luhn/37828224631 throughput [255530442.018op/s; 255596490.504op/s] or [-0.013%; +0.013%] None None None
credit_card/is_card_number_no_luhn/378282246310005 execution_time [55.407µs; 55.451µs] or [-0.040%; +0.040%] None None None
credit_card/is_card_number_no_luhn/378282246310005 throughput [18034055.108op/s; 18048377.190op/s] or [-0.040%; +0.040%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time [52.843µs; 52.862µs] or [-0.018%; +0.018%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput [18917307.904op/s; 18923972.086op/s] or [-0.018%; +0.018%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 execution_time [6.437µs; 6.438µs] or [-0.012%; +0.012%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 throughput [155321867.538op/s; 155357931.724op/s] or [-0.012%; +0.012%] None None None

Group 7

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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.159µs 3.231µs ± 1.429µs 3.006µs ± 0.029µs 3.038µs 3.685µs 14.075µs 14.777µs 391.64% 7.301 54.673 44.12% 0.101µ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.033µs; 3.429µs] or [-6.130%; +6.130%] None None None

Group 8

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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.951µs 26.101µs ± 9.966µs 18.163µs ± 0.148µs 34.915µs 44.305µs 46.016µs 66.078µs 263.80% 0.905 0.297 38.09% 0.705µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
two way interface execution_time [24.720µs; 27.483µs] or [-5.292%; +5.292%] None None None

Group 9

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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 8.278ms 8.297ms ± 0.010ms 8.298ms ± 0.006ms 8.303ms 8.313ms 8.333ms 8.336ms 0.47% 1.064 2.289 0.12% 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 [8.296ms; 8.299ms] or [-0.017%; +0.017%] None None None

Group 10

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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 5.001µs 5.065µs ± 0.048µs 5.047µs ± 0.025µs 5.093µs 5.154µs 5.156µs 5.185µs 2.74% 0.770 -0.805 0.94% 0.003µ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.059µs; 5.072µs] or [-0.131%; +0.131%] None None None

Group 11

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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 71.695ms 71.941ms ± 0.138ms 71.910ms ± 0.056ms 71.978ms 72.258ms 72.397ms 72.522ms 0.85% 1.584 2.930 0.19% 0.010ms 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 [71.922ms; 71.960ms] or [-0.027%; +0.027%] None None None

Group 12

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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 204.965µs 205.505µs ± 0.291µs 205.473µs ± 0.156µs 205.650µs 206.014µs 206.353µs 207.156µs 0.82% 1.491 4.947 0.14% 0.021µs 1 200
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput 4827286.222op/s 4866064.169op/s ± 6867.536op/s 4866809.563op/s ± 3705.491op/s 4870340.832op/s 4875262.008op/s 4877047.852op/s 4878891.410op/s 0.25% -1.471 4.827 0.14% 485.608op/s 1 200
normalization/normalize_name/normalize_name/bad-name execution_time 18.236µs 18.372µs ± 0.127µs 18.336µs ± 0.049µs 18.399µs 18.590µs 18.814µs 18.958µs 3.39% 1.734 3.450 0.69% 0.009µs 1 200
normalization/normalize_name/normalize_name/bad-name throughput 52749396.042op/s 54431787.843op/s ± 371305.920op/s 54537759.265op/s ± 145606.832op/s 54659573.847op/s 54824596.766op/s 54832026.235op/s 54835475.142op/s 0.55% -1.684 3.200 0.68% 26255.293op/s 1 200
normalization/normalize_name/normalize_name/good execution_time 10.643µs 10.813µs ± 0.076µs 10.805µs ± 0.052µs 10.864µs 10.938µs 10.987µs 11.030µs 2.08% 0.352 -0.263 0.71% 0.005µs 1 200
normalization/normalize_name/normalize_name/good throughput 90663274.522op/s 92483315.765op/s ± 652231.253op/s 92547489.827op/s ± 446578.483op/s 92979233.890op/s 93436533.563op/s 93754615.716op/s 93960829.093op/s 1.53% -0.318 -0.295 0.70% 46119.714op/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 [205.465µs; 205.546µs] or [-0.020%; +0.020%] None None None
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput [4865112.394op/s; 4867015.943op/s] or [-0.020%; +0.020%] None None None
normalization/normalize_name/normalize_name/bad-name execution_time [18.355µs; 18.390µs] or [-0.096%; +0.096%] None None None
normalization/normalize_name/normalize_name/bad-name throughput [54380328.413op/s; 54483247.272op/s] or [-0.095%; +0.095%] None None None
normalization/normalize_name/normalize_name/good execution_time [10.803µs; 10.824µs] or [-0.098%; +0.098%] None None None
normalization/normalize_name/normalize_name/good throughput [92392922.786op/s; 92573708.744op/s] or [-0.098%; +0.098%] None None None

Group 13

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 26d59f7 1752104241 ekump/APMSP-2151-create-ddsketch-ffi-crate
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 34.168µs 34.523µs ± 0.607µs 34.270µs ± 0.048µs 34.333µs 35.683µs 35.759µs 38.828µs 13.30% 2.819 11.856 1.75% 0.043µ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 [34.438µs; 34.607µs] or [-0.244%; +0.244%] None None None

Baseline

Omitted due to size.

@ekump
Copy link
Contributor Author

ekump commented Jul 9, 2025

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so.debug 22.10 MB 22.11 MB +.06% (+15.57 KB) 🔍
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 70.23 MB 70.27 MB +.05% (+41.13 KB) 🔍
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 9.24 MB 9.24 MB +.02% (+2.75 KB) 🔍
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 9.09 MB 9.16 MB +.71% (+66.24 KB) 🔍
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so.debug 26.15 MB 26.17 MB +.06% (+18.44 KB) 🔍
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 82.44 MB 82.49 MB +.05% (+45.80 KB) 🔍
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 18.37 MB 18.37 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 64.26 KB 64.26 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 124.63 MB 124.57 MB --.05% (-64.00 KB) 💪
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 643.66 MB 643.66 MB +0% (+1.03 KB) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 5.86 MB 5.86 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 64.26 KB 64.26 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 17.33 MB 17.33 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 32.13 MB 32.13 MB +0% (+20 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 15.66 MB 15.66 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 65.25 KB 65.25 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 126.89 MB 126.90 MB +0% (+8.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 633.29 MB 633.29 MB +0% (+1.03 KB) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 4.47 MB 4.47 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 65.25 KB 65.25 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 18.47 MB 18.47 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 30.18 MB 30.18 MB +0% (+16 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 62.95 MB 62.99 MB +.06% (+38.82 KB) 🔍
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 9.83 MB 9.84 MB +.06% (+6.06 KB) 🔍
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so.debug 20.95 MB 20.96 MB +.07% (+15.14 KB) 🔍
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 77.42 MB 77.46 MB +.04% (+35.53 KB) 🔍
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 9.74 MB 9.74 MB +.01% (+1.65 KB) 🔍
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so.debug 24.08 MB 24.10 MB +.06% (+15.03 KB) 🔍

@ekump ekump force-pushed the ekump/APMSP-2151-create-ddsketch-ffi-crate branch from c10edbf to c7e835c Compare July 9, 2025 19:17
@github-actions github-actions bot added profiling Relates to the profiling* modules. ci-build labels Jul 9, 2025
@ekump ekump force-pushed the ekump/APMSP-2151-create-ddsketch-ffi-crate branch from c7e835c to d10aeef Compare July 9, 2025 19:23
@ekump ekump marked this pull request as ready for review July 9, 2025 19:23
@ekump ekump requested review from a team as code owners July 9, 2025 19:23
@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2025

Codecov Report

Attention: Patch coverage is 80.46512% with 42 lines in your changes missing coverage. Please review.

Project coverage is 71.27%. Comparing base (b708db7) to head (26d59f7).

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1135    +/-   ##
========================================
  Coverage   71.27%   71.27%            
========================================
  Files         343      346     +3     
  Lines       52396    52611   +215     
========================================
+ Hits        37347    37501   +154     
- Misses      15049    15110    +61     
Components Coverage Δ
datadog-crashtracker 43.91% <ø> (ø)
datadog-crashtracker-ffi 5.93% <ø> (ø)
datadog-alloc 98.73% <ø> (ø)
data-pipeline 89.21% <ø> (ø)
data-pipeline-ffi 87.55% <ø> (ø)
ddcommon 82.98% <100.00%> (+0.09%) ⬆️
ddcommon-ffi 70.17% <100.00%> (+0.51%) ⬆️
ddtelemetry 60.08% <ø> (ø)
ddtelemetry-ffi 21.32% <ø> (ø)
dogstatsd-client 83.26% <ø> (ø)
datadog-ipc 82.58% <ø> (-0.11%) ⬇️
datadog-profiling 77.13% <ø> (ø)
datadog-profiling-ffi 62.12% <ø> (ø)
datadog-sidecar 40.28% <ø> (ø)
datdog-sidecar-ffi 5.17% <ø> (ø)
spawn-worker 55.35% <ø> (ø)
tinybytes 90.96% <ø> (ø)
datadog-trace-normalization 98.24% <ø> (ø)
datadog-trace-obfuscation 94.17% <ø> (ø)
datadog-trace-protobuf 77.10% <ø> (ø)
datadog-trace-utils 89.04% <ø> (ø)
datadog-tracer-flare 78.54% <ø> (ø)
datadog-log 76.31% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

Nice to see ddsketch joining the family! :D

@@ -79,6 +79,7 @@ COPY "ddtelemetry-ffi/Cargo.toml" "ddtelemetry-ffi/"
COPY "datadog-log/Cargo.toml" "datadog-log/"
COPY "datadog-log-ffi/Cargo.toml" "datadog-log-ffi/"
COPY "ddsketch/Cargo.toml" "ddsketch/"
COPY "ddsketch-ffi/Cargo.toml" "ddsketch-ffi/"
Copy link
Member

Choose a reason for hiding this comment

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

Minor: I see a cargo run --bin release ... below what doesn't list ddsketch... Should it?

Comment on lines -6 to 7
cargo run --bin release --features profiling,telemetry,data-pipeline,symbolizer,crashtracker,library-config,log --release -- --out
cargo run --bin release --features profiling,telemetry,data-pipeline,symbolizer,crashtracker,library-config,log,ddsketch --release -- --out
```
Copy link
Member

Choose a reason for hiding this comment

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

Minor: I'm a bit surprised there's no single place we can update with this... Should we maybe replace it with build-profiling-ffi or something similar?


[export]
include = ["ddsketch-ffi"]
prefix = "ddog_"
Copy link
Member

Choose a reason for hiding this comment

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

Should this be ddog_ddsketch by default?

Suggested change
prefix = "ddog_"
prefix = "ddog_ddsketch"

Copy link
Contributor

Choose a reason for hiding this comment

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

Or possibly just ddsketch. Like if we were greenfielding this thing I'd say ddog_sketch but ddsketch has been used for years as a name and I believe that includes papers and such.

Comment on lines +26 to +41
/// Structure that contains error information that DDSketch FFI API can return.
#[repr(C)]
#[derive(Debug)]
pub struct DDSketchError {
pub code: DDSketchErrorCode,
pub msg: CString,
}

impl DDSketchError {
pub fn new(code: DDSketchErrorCode, msg: &str) -> Self {
Self {
code,
msg: CString::new_or_empty(msg),
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious about the need for this -- is ddcommon_ffi::Result and ddcommon_ffi::Error not usable for the same purpose?

Comment on lines +56 to +58
pub unsafe extern "C" fn ddog_ddsketch_error_free(error: Option<Box<DDSketchError>>) {
drop(error)
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm hoping we may be able to move away from the ddsketch-specific error code; but if not, I think this should be _drop, not _free, for consistency with other apis?

Comment on lines +7 to +48
/// A bin from a DDSketch containing a value and its weight.
#[repr(C)]
#[derive(Clone, Copy)]
pub struct DDSketchBin {
pub value: f64,
pub weight: f64,
}

/// Returns the ordered bins from the DDSketch.
///
/// # Safety
///
/// The `sketch` parameter must be a valid pointer to a DDSketch instance.
/// The returned bins must be freed with `ddog_ddsketch_bins_drop`.
/// Returns empty bins if sketch is null.
#[no_mangle]
pub unsafe extern "C" fn ddog_ddsketch_ordered_bins(
sketch: Option<&DDSketch>,
) -> ffi::Vec<DDSketchBin> {
let sketch = match sketch {
Some(s) => s,
None => return ffi::Vec::new(),
};

let bins = sketch.ordered_bins();
let result: Vec<DDSketchBin> = bins
.into_iter()
.map(|(value, weight)| DDSketchBin { value, weight })
.collect();

ffi::Vec::from(result)
}

/// Drops a DDSketchBins instance.
///
/// # Safety
///
/// Only pass a valid DDSketchBins instance.
#[no_mangle]
pub unsafe extern "C" fn ddog_ddsketch_bins_drop(bins: ffi::Vec<DDSketchBin>) {
drop(bins);
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious -- do we need to expose this part of the API? Is it mostly for tests? E.g. My understanding of ddsketch is that it was mostly a write-only affair -- drop points in, and at the end, get the "gist" of it and report it back.

Comment on lines +71 to +97
fn test_ddsketch_bins_manual() {
let bins_vec = vec![
DDSketchBin {
value: 1.0,
weight: 1.0,
},
DDSketchBin {
value: 2.0,
weight: 1.0,
},
];

let bins = ffi::Vec::from(bins_vec);
assert_eq!(bins.len(), 2);
assert!(!bins.is_empty());

// Test that we can access the data through the slice
let slice = bins.as_slice();
assert_eq!(slice[0].value, 1.0);
assert_eq!(slice[0].weight, 1.0);
assert_eq!(slice[1].value, 2.0);
assert_eq!(slice[1].weight, 1.0);

unsafe {
ddog_ddsketch_bins_drop(bins);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite understand this test -- what are we testing here again?

Comment on lines +86 to +96
#[test]
fn test_error_with_null_bytes() {
let code = DDSketchErrorCode::InvalidInput;
let error = Box::new(DDSketchError::new(code, "Error with\0null bytes"));

assert_eq!(error.code, DDSketchErrorCode::InvalidInput);
let msg = error.msg.as_cstr().into_std().to_str().unwrap();
assert_eq!(msg, ""); // Should fall back to empty string

unsafe { ddog_ddsketch_error_free(Some(error)) };
}
Copy link
Member

Choose a reason for hiding this comment

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

Re: my comment in ddcommon for the null bytes in the middle of the string, I don't quite understand how this would happen in normal code? 👀

Comment on lines +69 to +70
// Clean up the sketch (note: sketch is consumed by ddog_ddsketch_encode)
// ddog_ddsketch_drop is not called here because the sketch was consumed
Copy link
Member

Choose a reason for hiding this comment

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

This "the pointer gets consumed" design is a bit error-prone to the caller, which has just been left with a dangling pointer.

One thing we've done in a lot of the profiling apis is to require that the pointer location gets passed in, and set it to NULL when we consume the pointer, so that it doesn't get accidentally reused.

Comment on lines +29 to +32
pub struct DDSketchError {
pub code: DDSketchErrorCode,
pub msg: CString,
}
Copy link
Member

Choose a reason for hiding this comment

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

If we do keep DDSketchError (see my note below), I believe it should be renamed ddog_ddsketch_DDSketchError / ddog_ddsketch_DDSketchErrorCode, right now it's missing the prefixes in the .h files 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-build common profiling Relates to the profiling* modules.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants