Skip to content

Conversation

@dd-oleksii
Copy link
Contributor

What does this PR do?

Add pyo3 conversion methods for datadog-ffe.

Motivation

This will allow our Python tracer to easily call into datadog-ffe with Rust automatically doing conversion from Python to Rust types (and vice versa)

How to test the change?

Will be tested as part of ddtrace.

@dd-oleksii dd-oleksii requested a review from avara1986 October 30, 2025 02:12
@dd-oleksii dd-oleksii requested review from a team as code owners October 30, 2025 02:12
Comment on lines +59 to +76
/// Accepts either a dict with `"targeting_key"` and `"attributes"` items, or any object with
/// `targeting_key` and `attributes` attributes.
///
/// # Examples
///
/// ```python
/// {"targeting_key": "user1", "attributes": {"attr1": 42}}
/// ```
///
/// ```python
/// @dataclass
/// class EvaluationContext:
/// targeting_key: Optional[str]
/// attributes: dict[str, Any]
///
/// EvaluationContext(targeting_key="user1", attributes={"attr1": 42})
/// ```
impl<'py> FromPyObject<'py> for EvaluationContext {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@avara1986 for evaluation context, either a dict or an object with targeting_key/attributes is accepted. (We can technically pass OF's EvaluationContext if we filter out unsupported attributes.)

@pr-commenter
Copy link

pr-commenter bot commented Oct 30, 2025

Benchmarks

Comparison

Benchmark execution time: 2025-11-01 02:04:20

Comparing candidate commit 36fe6be in PR branch ffe-pyo3-methods with baseline commit 21b4481 in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 55 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 36fe6be 1761961816 ffe-pyo3-methods
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 238.812ns 250.688ns ± 14.815ns 245.282ns ± 4.430ns 252.325ns 286.097ns 298.773ns 300.350ns 22.45% 1.988 3.087 5.89% 1.048ns 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 [248.635ns; 252.741ns] or [-0.819%; +0.819%] None None None

Group 2

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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 185.667µs 186.074µs ± 0.185µs 186.048µs ± 0.138µs 186.217µs 186.394µs 186.476µs 186.501µs 0.24% 0.169 -0.585 0.10% 0.013µs 1 200
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput 5361892.201op/s 5374201.281op/s ± 5349.112op/s 5374958.084op/s ± 3994.081op/s 5378241.290op/s 5382412.759op/s 5385575.687op/s 5385991.091op/s 0.21% -0.165 -0.586 0.10% 378.239op/s 1 200
normalization/normalize_name/normalize_name/bad-name execution_time 17.810µs 17.902µs ± 0.033µs 17.906µs ± 0.021µs 17.923µs 17.948µs 17.980µs 18.007µs 0.57% -0.132 0.194 0.19% 0.002µs 1 200
normalization/normalize_name/normalize_name/bad-name throughput 55533570.277op/s 55859808.998op/s ± 104287.171op/s 55847424.836op/s ± 66492.971op/s 55925343.096op/s 56041644.891op/s 56119730.199op/s 56147913.421op/s 0.54% 0.144 0.191 0.19% 7374.217op/s 1 200
normalization/normalize_name/normalize_name/good execution_time 10.522µs 10.578µs ± 0.025µs 10.576µs ± 0.020µs 10.597µs 10.614µs 10.633µs 10.639µs 0.59% 0.045 -0.733 0.23% 0.002µs 1 200
normalization/normalize_name/normalize_name/good throughput 93997977.967op/s 94536277.724op/s ± 220787.621op/s 94551079.055op/s ± 180398.084op/s 94697893.840op/s 94877735.734op/s 94974465.392op/s 95037380.160op/s 0.51% -0.037 -0.736 0.23% 15612.042op/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 [186.049µs; 186.100µs] or [-0.014%; +0.014%] None None None
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput [5373459.945op/s; 5374942.616op/s] or [-0.014%; +0.014%] None None None
normalization/normalize_name/normalize_name/bad-name execution_time [17.897µs; 17.907µs] or [-0.026%; +0.026%] None None None
normalization/normalize_name/normalize_name/bad-name throughput [55845355.799op/s; 55874262.197op/s] or [-0.026%; +0.026%] None None None
normalization/normalize_name/normalize_name/good execution_time [10.575µs; 10.581µs] or [-0.032%; +0.032%] None None None
normalization/normalize_name/normalize_name/good throughput [94505678.683op/s; 94566876.765op/s] or [-0.032%; +0.032%] None None None

Group 3

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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.326µs 2.400µs ± 0.015µs 2.399µs ± 0.005µs 2.408µs 2.423µs 2.431µs 2.436µs 1.54% -1.425 4.738 0.64% 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.397µs; 2.402µs] or [-0.089%; +0.089%] None None None

Group 4

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
single_flag_killswitch/rules-based execution_time 170.764ns 174.665ns ± 2.798ns 174.255ns ± 1.635ns 176.427ns 179.746ns 183.202ns 184.932ns 6.13% 0.947 0.895 1.60% 0.198ns 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
single_flag_killswitch/rules-based execution_time [174.278ns; 175.053ns] or [-0.222%; +0.222%] None None None

Group 5

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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 158.736µs 159.684µs ± 0.382µs 159.591µs ± 0.115µs 159.771µs 160.286µs 160.864µs 162.891µs 2.07% 3.780 25.453 0.24% 0.027µ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 [159.631µs; 159.737µs] or [-0.033%; +0.033%] None None None

Group 6

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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 10.672ms 10.712ms ± 0.018ms 10.713ms ± 0.011ms 10.724ms 10.739ms 10.752ms 10.806ms 0.87% 0.730 3.209 0.17% 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 [10.710ms; 10.715ms] or [-0.023%; +0.023%] None None None

Group 7

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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 60.463ms 61.107ms ± 1.894ms 60.860ms ± 0.066ms 60.925ms 61.275ms 70.567ms 80.212ms 31.80% 8.395 73.097 3.09% 0.134ms 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 [60.844ms; 61.369ms] or [-0.429%; +0.429%] None None None

Group 8

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
benching serializing traces from their internal representation to msgpack execution_time 14.179ms 14.236ms ± 0.028ms 14.233ms ± 0.012ms 14.244ms 14.267ms 14.349ms 14.390ms 1.11% 2.390 8.986 0.19% 0.002ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
benching serializing traces from their internal representation to msgpack execution_time [14.233ms; 14.240ms] or [-0.027%; +0.027%] None None None

Group 9

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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 85.730µs 86.081µs ± 0.311µs 86.052µs ± 0.053µs 86.109µs 86.233µs 86.489µs 90.088µs 4.69% 11.002 137.576 0.36% 0.022µ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.038µs; 86.124µ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 36fe6be 1761961816 ffe-pyo3-methods
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.896µs 3.915µs ± 0.003µs 3.914µs ± 0.001µs 3.916µs 3.918µs 3.921µs 3.924µs 0.24% -1.443 13.356 0.06% 0.000µs 1 200
credit_card/is_card_number/ throughput 254844158.558op/s 255448156.103op/s ± 165587.866op/s 255462498.107op/s ± 93996.263op/s 255546004.670op/s 255639343.949op/s 255713057.315op/s 256659355.977op/s 0.47% 1.469 13.551 0.06% 11708.830op/s 1 200
credit_card/is_card_number/ 3782-8224-6310-005 execution_time 77.907µs 78.763µs ± 0.707µs 78.569µs ± 0.438µs 79.219µs 80.229µs 80.902µs 81.303µs 3.48% 1.107 0.998 0.90% 0.050µs 1 200
credit_card/is_card_number/ 3782-8224-6310-005 throughput 12299672.685op/s 12697273.208op/s ± 112935.998op/s 12727633.276op/s ± 70885.258op/s 12782851.500op/s 12828371.300op/s 12834443.669op/s 12835846.669op/s 0.85% -1.060 0.847 0.89% 7985.781op/s 1 200
credit_card/is_card_number/ 378282246310005 execution_time 71.455µs 71.829µs ± 0.274µs 71.791µs ± 0.201µs 72.002µs 72.349µs 72.597µs 72.995µs 1.68% 1.091 1.406 0.38% 0.019µs 1 200
credit_card/is_card_number/ 378282246310005 throughput 13699511.755op/s 13922230.390op/s ± 52916.736op/s 13929277.953op/s ± 39191.998op/s 13967818.999op/s 13983112.053op/s 13990062.627op/s 13994917.731op/s 0.47% -1.066 1.309 0.38% 3741.778op/s 1 200
credit_card/is_card_number/37828224631 execution_time 3.896µs 3.915µs ± 0.003µs 3.914µs ± 0.002µs 3.916µs 3.919µs 3.921µs 3.922µs 0.20% -1.142 9.163 0.07% 0.000µs 1 200
credit_card/is_card_number/37828224631 throughput 254952023.799op/s 255456622.309op/s ± 177495.588op/s 255460965.760op/s ± 103792.440op/s 255560830.834op/s 255691882.514op/s 255770171.846op/s 256650968.149op/s 0.47% 1.163 9.305 0.07% 12550.833op/s 1 200
credit_card/is_card_number/378282246310005 execution_time 68.235µs 68.610µs ± 0.321µs 68.555µs ± 0.237µs 68.830µs 69.183µs 69.647µs 69.676µs 1.64% 1.063 0.849 0.47% 0.023µs 1 200
credit_card/is_card_number/378282246310005 throughput 14352121.637op/s 14575373.405op/s ± 67757.741op/s 14586906.065op/s ± 50704.544op/s 14635363.071op/s 14649441.279op/s 14653356.564op/s 14655325.319op/s 0.47% -1.039 0.770 0.46% 4791.196op/s 1 200
credit_card/is_card_number/37828224631000521389798 execution_time 45.417µs 45.719µs ± 0.103µs 45.726µs ± 0.072µs 45.792µs 45.873µs 45.923µs 45.954µs 0.50% -0.265 -0.200 0.22% 0.007µs 1 200
credit_card/is_card_number/37828224631000521389798 throughput 21760677.264op/s 21872871.708op/s ± 49184.512op/s 21869578.325op/s ± 34248.022op/s 21906249.311op/s 21954341.057op/s 22007042.260op/s 22018167.099op/s 0.68% 0.277 -0.186 0.22% 3477.870op/s 1 200
credit_card/is_card_number/x371413321323331 execution_time 6.584µs 6.634µs ± 0.011µs 6.637µs ± 0.005µs 6.641µs 6.646µs 6.649µs 6.650µs 0.21% -1.480 2.913 0.16% 0.001µs 1 200
credit_card/is_card_number/x371413321323331 throughput 150365263.115op/s 150743067.405op/s ± 240688.385op/s 150679046.125op/s ± 116256.791op/s 150860401.418op/s 151179015.626op/s 151477336.373op/s 151877884.548op/s 0.80% 1.493 2.978 0.16% 17019.239op/s 1 200
credit_card/is_card_number_no_luhn/ execution_time 3.895µs 3.915µs ± 0.003µs 3.915µs ± 0.002µs 3.917µs 3.919µs 3.922µs 3.923µs 0.19% -1.612 12.487 0.07% 0.000µs 1 200
credit_card/is_card_number_no_luhn/ throughput 254911487.625op/s 255396667.176op/s ± 187017.310op/s 255399770.141op/s ± 109353.545op/s 255502756.905op/s 255630549.460op/s 255750285.314op/s 256752262.818op/s 0.53% 1.638 12.696 0.07% 13224.121op/s 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time 65.613µs 65.735µs ± 0.051µs 65.734µs ± 0.039µs 65.775µs 65.812µs 65.843µs 65.853µs 0.18% -0.045 -0.610 0.08% 0.004µs 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput 15185284.288op/s 15212541.906op/s ± 11767.056op/s 15212759.389op/s ± 9096.928op/s 15221774.918op/s 15231375.722op/s 15237819.656op/s 15240836.596op/s 0.18% 0.049 -0.610 0.08% 832.057op/s 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time 53.366µs 53.437µs ± 0.038µs 53.427µs ± 0.027µs 53.468µs 53.505µs 53.531µs 53.556µs 0.24% 0.569 -0.432 0.07% 0.003µs 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 throughput 18672190.722op/s 18713545.955op/s ± 13443.670op/s 18717164.382op/s ± 9498.262op/s 18724004.881op/s 18730961.516op/s 18734461.330op/s 18738535.729op/s 0.11% -0.566 -0.437 0.07% 950.611op/s 1 200
credit_card/is_card_number_no_luhn/37828224631 execution_time 3.901µs 3.915µs ± 0.003µs 3.914µs ± 0.001µs 3.916µs 3.919µs 3.921µs 3.922µs 0.20% -0.222 4.619 0.06% 0.000µs 1 200
credit_card/is_card_number_no_luhn/37828224631 throughput 254950853.082op/s 255448809.270op/s ± 163826.920op/s 255470190.435op/s ± 94405.943op/s 255559462.720op/s 255650362.244op/s 255742847.072op/s 256374222.044op/s 0.35% 0.234 4.677 0.06% 11584.313op/s 1 200
credit_card/is_card_number_no_luhn/378282246310005 execution_time 50.149µs 50.210µs ± 0.030µs 50.207µs ± 0.019µs 50.226µs 50.264µs 50.284µs 50.331µs 0.25% 0.702 0.628 0.06% 0.002µs 1 200
credit_card/is_card_number_no_luhn/378282246310005 throughput 19868606.916op/s 19916305.336op/s ± 11839.381op/s 19917620.721op/s ± 7692.244op/s 19925380.447op/s 19933610.016op/s 19935917.787op/s 19940596.962op/s 0.12% -0.699 0.618 0.06% 837.171op/s 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time 45.454µs 45.715µs ± 0.098µs 45.711µs ± 0.068µs 45.791µs 45.872µs 45.929µs 45.968µs 0.56% -0.040 -0.349 0.21% 0.007µs 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput 21754451.840op/s 21874814.130op/s ± 47094.212op/s 21876574.564op/s ± 32372.885op/s 21906522.668op/s 21950765.976op/s 21983778.635op/s 22000228.642op/s 0.57% 0.051 -0.346 0.21% 3330.064op/s 1 200
credit_card/is_card_number_no_luhn/x371413321323331 execution_time 6.564µs 6.624µs ± 0.016µs 6.628µs ± 0.009µs 6.636µs 6.643µs 6.646µs 6.647µs 0.29% -1.366 2.138 0.24% 0.001µs 1 200
credit_card/is_card_number_no_luhn/x371413321323331 throughput 150441081.295op/s 150956489.719op/s ± 357205.901op/s 150884852.233op/s ± 208271.972op/s 151109433.488op/s 151665546.420op/s 152149015.842op/s 152344654.862op/s 0.97% 1.382 2.197 0.24% 25258.271op/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.914µs; 3.915µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/ throughput [255425207.217op/s; 255471104.989op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 execution_time [78.665µs; 78.861µs] or [-0.124%; +0.124%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 throughput [12681621.365op/s; 12712925.051op/s] or [-0.123%; +0.123%] None None None
credit_card/is_card_number/ 378282246310005 execution_time [71.791µs; 71.867µs] or [-0.053%; +0.053%] None None None
credit_card/is_card_number/ 378282246310005 throughput [13914896.639op/s; 13929564.140op/s] or [-0.053%; +0.053%] None None None
credit_card/is_card_number/37828224631 execution_time [3.914µs; 3.915µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/37828224631 throughput [255432023.128op/s; 255481221.491op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/378282246310005 execution_time [68.566µs; 68.655µs] or [-0.065%; +0.065%] None None None
credit_card/is_card_number/378282246310005 throughput [14565982.834op/s; 14584763.976op/s] or [-0.064%; +0.064%] None None None
credit_card/is_card_number/37828224631000521389798 execution_time [45.705µs; 45.733µs] or [-0.031%; +0.031%] None None None
credit_card/is_card_number/37828224631000521389798 throughput [21866055.208op/s; 21879688.208op/s] or [-0.031%; +0.031%] None None None
credit_card/is_card_number/x371413321323331 execution_time [6.632µs; 6.635µs] or [-0.022%; +0.022%] None None None
credit_card/is_card_number/x371413321323331 throughput [150709710.309op/s; 150776424.500op/s] or [-0.022%; +0.022%] None None None
credit_card/is_card_number_no_luhn/ execution_time [3.915µs; 3.916µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/ throughput [255370748.375op/s; 255422585.976op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time [65.728µs; 65.742µs] or [-0.011%; +0.011%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput [15210911.105op/s; 15214172.707op/s] or [-0.011%; +0.011%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time [53.432µs; 53.443µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 throughput [18711682.792op/s; 18715409.118op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/37828224631 execution_time [3.914µs; 3.915µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/37828224631 throughput [255426104.435op/s; 255471514.106op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/378282246310005 execution_time [50.206µs; 50.214µs] or [-0.008%; +0.008%] None None None
credit_card/is_card_number_no_luhn/378282246310005 throughput [19914664.512op/s; 19917946.161op/s] or [-0.008%; +0.008%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time [45.701µs; 45.729µs] or [-0.030%; +0.030%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput [21868287.325op/s; 21881340.935op/s] or [-0.030%; +0.030%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 execution_time [6.622µs; 6.627µs] or [-0.033%; +0.033%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 throughput [150906984.416op/s; 151005995.021op/s] or [-0.033%; +0.033%] None None None

Group 11

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
receiver_entry_point/report/2597 execution_time 6.089ms 6.376ms ± 0.057ms 6.377ms ± 0.019ms 6.397ms 6.459ms 6.499ms 6.542ms 2.59% -1.745 8.142 0.90% 0.004ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
receiver_entry_point/report/2597 execution_time [6.368ms; 6.384ms] or [-0.125%; +0.125%] None None None

Group 12

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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.968µs 5.041µs ± 0.039µs 5.063µs ± 0.018µs 5.076µs 5.081µs 5.083µs 5.086µs 0.45% -0.402 -1.531 0.76% 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.036µs; 5.046µs] or [-0.106%; +0.106%] None None None

Group 13

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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 496.199µs 497.068µs ± 0.746µs 496.961µs ± 0.291µs 497.291µs 497.797µs 500.477µs 504.102µs 1.44% 5.382 43.067 0.15% 0.053µs 1 200
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput 1983726.609op/s 2011803.216op/s ± 2993.521op/s 2012229.549op/s ± 1178.264op/s 2013309.598op/s 2014570.290op/s 2015181.734op/s 2015322.271op/s 0.15% -5.310 42.157 0.15% 211.674op/s 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time 370.124µs 371.070µs ± 0.357µs 371.054µs ± 0.216µs 371.276µs 371.614µs 372.096µs 372.723µs 0.45% 0.479 1.969 0.10% 0.025µs 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput 2682954.768op/s 2694912.091op/s ± 2590.628op/s 2695022.996op/s ± 1565.089op/s 2696413.738op/s 2699302.470op/s 2700636.389op/s 2701794.696op/s 0.25% -0.468 1.936 0.10% 183.185op/s 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time 168.459µs 168.791µs ± 0.150µs 168.773µs ± 0.087µs 168.859µs 169.065µs 169.243µs 169.381µs 0.36% 0.883 1.308 0.09% 0.011µs 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput 5903854.764op/s 5924482.369op/s ± 5270.882op/s 5925103.250op/s ± 3048.965op/s 5928165.456op/s 5931224.119op/s 5934793.999op/s 5936173.162op/s 0.19% -0.877 1.291 0.09% 372.708op/s 1 200
normalization/normalize_service/normalize_service/[empty string] execution_time 36.084µs 36.362µs ± 0.091µs 36.352µs ± 0.053µs 36.415µs 36.494µs 36.626µs 36.739µs 1.07% 0.694 2.236 0.25% 0.006µs 1 200
normalization/normalize_service/normalize_service/[empty string] throughput 27219079.486op/s 27501508.324op/s ± 68404.831op/s 27509018.710op/s ± 39824.146op/s 27541650.877op/s 27604421.977op/s 27646148.728op/s 27713484.306op/s 0.74% -0.666 2.173 0.25% 4836.952op/s 1 200
normalization/normalize_service/normalize_service/test_ASCII execution_time 46.188µs 46.307µs ± 0.125µs 46.286µs ± 0.033µs 46.327µs 46.421µs 46.472µs 47.871µs 3.42% 9.852 119.992 0.27% 0.009µs 1 200
normalization/normalize_service/normalize_service/test_ASCII throughput 20889653.192op/s 21595120.564op/s ± 56888.458op/s 21604659.698op/s ± 15602.888op/s 21617013.888op/s 21633192.618op/s 21645977.444op/s 21650504.565op/s 0.21% -9.651 116.597 0.26% 4022.621op/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 [496.964µs; 497.171µs] or [-0.021%; +0.021%] None None None
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput [2011388.342op/s; 2012218.089op/s] or [-0.021%; +0.021%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time [371.021µs; 371.119µs] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput [2694553.055op/s; 2695271.127op/s] or [-0.013%; +0.013%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time [168.770µs; 168.812µs] or [-0.012%; +0.012%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput [5923751.876op/s; 5925212.863op/s] or [-0.012%; +0.012%] None None None
normalization/normalize_service/normalize_service/[empty string] execution_time [36.349µs; 36.374µs] or [-0.035%; +0.035%] None None None
normalization/normalize_service/normalize_service/[empty string] throughput [27492028.073op/s; 27510988.576op/s] or [-0.034%; +0.034%] None None None
normalization/normalize_service/normalize_service/test_ASCII execution_time [46.290µs; 46.324µs] or [-0.037%; +0.037%] None None None
normalization/normalize_service/normalize_service/test_ASCII throughput [21587236.371op/s; 21603004.757op/s] or [-0.037%; +0.037%] None None None

Group 14

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
sdk_test_data/rules-based execution_time 121.756µs 123.266µs ± 1.258µs 123.060µs ± 0.432µs 123.508µs 124.442µs 128.004µs 135.539µs 10.14% 5.793 47.852 1.02% 0.089µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
sdk_test_data/rules-based execution_time [123.092µs; 123.440µs] or [-0.141%; +0.141%] None None None

Group 15

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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.226µs 3.210µs ± 1.414µs 2.997µs ± 0.025µs 3.024µs 3.670µs 13.775µs 14.752µs 392.21% 7.324 54.909 43.93% 0.100µ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.014µs; 3.406µs] or [-6.104%; +6.104%] None None None

Group 16

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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.973µs 33.565µs ± 1.092µs 33.063µs ± 0.039µs 33.133µs 35.912µs 35.982µs 36.760µs 11.18% 1.712 0.990 3.24% 0.077µ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.414µs; 33.716µs] or [-0.451%; +0.451%] None None None

Group 17

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 36fe6be 1761961816 ffe-pyo3-methods
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.655µs 25.606µs ± 9.958µs 17.864µs ± 0.131µs 34.700µs 41.142µs 49.789µs 73.956µs 314.00% 1.059 1.351 38.79% 0.704µ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.226µs; 26.986µs] or [-5.390%; +5.390%] None None None

Baseline

Omitted due to size.

@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 44.31818% with 98 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.00%. Comparing base (21b4481) to head (36fe6be).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1289      +/-   ##
==========================================
- Coverage   72.03%   72.00%   -0.03%     
==========================================
  Files         369      369              
  Lines       58241    58328      +87     
==========================================
+ Hits        41953    42001      +48     
- Misses      16288    16327      +39     
Components Coverage Δ
datadog-crashtracker 50.63% <ø> (ø)
datadog-crashtracker-ffi 5.86% <ø> (ø)
datadog-alloc 98.73% <ø> (ø)
data-pipeline 88.19% <ø> (ø)
data-pipeline-ffi 88.19% <ø> (ø)
ddcommon 80.95% <ø> (ø)
ddcommon-ffi 73.84% <ø> (ø)
ddtelemetry 60.02% <ø> (ø)
ddtelemetry-ffi 21.24% <ø> (ø)
dogstatsd-client 83.26% <ø> (ø)
datadog-ipc 82.39% <ø> (ø)
datadog-profiling 76.50% <ø> (ø)
datadog-profiling-ffi 62.11% <ø> (ø)
datadog-sidecar 37.62% <ø> (ø)
datdog-sidecar-ffi 15.88% <ø> (ø)
spawn-worker 55.18% <ø> (ø)
tinybytes 92.44% <ø> (ø)
datadog-trace-normalization 98.24% <ø> (ø)
datadog-trace-obfuscation 94.17% <ø> (ø)
datadog-trace-protobuf 59.65% <ø> (ø)
datadog-trace-utils 90.19% <ø> (ø)
datadog-tracer-flare 64.98% <ø> (ø)
datadog-log 75.57% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dd-oleksii dd-oleksii requested a review from bantonsson October 30, 2025 02:32
@dd-octo-sts
Copy link

dd-octo-sts bot commented Oct 30, 2025

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.50 MB 7.50 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 82.73 MB 82.73 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 9.54 MB 9.54 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 95.91 MB 95.91 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 19.00 MB 19.00 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 65.77 KB 65.77 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 131.59 MB 131.59 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 692.97 MB 692.97 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 6.31 MB 6.31 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 65.77 KB 65.77 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 19.01 MB 19.01 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 36.80 MB 36.80 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 16.09 MB 16.09 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 66.79 KB 66.79 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 133.70 MB 133.70 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 681.01 MB 681.01 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 4.85 MB 4.85 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 66.79 KB 66.79 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 20.18 MB 20.18 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 34.56 MB 34.56 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 71.71 MB 71.71 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.91 MB 8.91 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 90.69 MB 90.69 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.25 MB 10.25 MB 0% (0 B) 👌

@avara1986
Copy link
Member

Correct me if I’m wrong, but libdatadog is language-agnostic and wouldn’t require pyo3, right?the bindings could be added directly in ddtrace-py like: https://github.com/DataDog/dd-trace-py/blob/main/src/native/ffande.rs

@dd-oleksii
Copy link
Contributor Author

Correct me if I’m wrong, but libdatadog is language-agnostic and wouldn’t require pyo3, right?the bindings could be added directly in ddtrace-py like: https://github.com/DataDog/dd-trace-py/blob/main/src/native/ffande.rs

Yes, somewhat.

The code here is not bindings per se but helper functions that can convert from Python to Rust and back. The reason for adding it here is to satisfy Rust's orphan rule—we technically cannot impl IntoPyObject/FromPyObject for datadog-ffe types outside of datadog-ffe. The two options are: either define these impls here, or create wrappers/custom functions in ddtrace-py. Wrappers are cumbersome and don't compose well (especially in types like HashMap<Str, Attribute> we would need to copy the whole hashmap just to add/remove wrappers).

The code here is added under "pyo3" feature, so other consumers of the library don't need to pull python-related dependencies. The way to think about it is that pyo3 is not a required dependency but "datadog-ffe can play nicely with pyo3 if you enable this feature."

Copy link

@leoromanovsky leoromanovsky left a comment

Choose a reason for hiding this comment

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

considering add a sanity test round trip data

/// - `bool`
/// - `NoneType`
///
/// Note that nesting is not currently supported and will throw an error.

Choose a reason for hiding this comment

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

👍

return Ok(Attribute(AttributeImpl::Number(s.value())));
}
if let Ok(s) = value.downcast::<PyInt>() {
return Ok(Attribute(AttributeImpl::Number(s.extract::<f64>()?)));

Choose a reason for hiding this comment

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

i64 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. We only support float attributes, so ints are squashed to floats here

targeting_key: targeting_key
.map(|it| it.extract())
.transpose()?
.unwrap_or_else(|| Str::from_static_str("").into()),

Choose a reason for hiding this comment

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

confirming empty strings are acceptable input

These will be defined in dd-trace-py to better match what Python/OF
need.
This reverts commit b9c68ca.

Test generation in build.rs made tests hard to edit.
This is required to allow tracers return more precise error codes.
Copy link

@leoromanovsky leoromanovsky left a comment

Choose a reason for hiding this comment

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

API improvement makes sense

Copy link
Member

@avara1986 avara1986 left a comment

Choose a reason for hiding this comment

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

The UniversalFlagConfigWire structure is not correct compared to the JSON object coming from Remote Config. Consider merging this branch (and please have an expert review it, it’s my first Rust commit):
https://github.com/DataDog/libdatadog/compare/ffe-pyo3-methods...avara1986/ffe-pyo3-methods?expand=1

@dd-oleksii
Copy link
Contributor Author

@avara1986 thanks for finding this! it's not quite related to pyo3 changes here but I fixed that by dropping support for JSON:API

@dd-oleksii dd-oleksii requested a review from avara1986 October 31, 2025 22:31
/// ffe-specific [`Error`] enum.
pub type Result<T> = std::result::Result<T, Error>;

/// Enum representing possible errors that can occur in the feature flagging SDK.

Choose a reason for hiding this comment

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

Just an FYI: removing this shouldn't impact anything from the FFI's perspective. The FFI converts all errors to a generic ddog_Error type using a wrap_with_ffi_result method

Within wrap_with_ffi_result, there's a anyhow::Error → ddcommon_ffi::Error conversion that flattens all error details into a string message

impl From<anyhow::Error> for Error {
fn from(value: anyhow::Error) -> Self {
// {:#} is the "alternate" format, see:
// https://docs.rs/anyhow/latest/anyhow/struct.Error.html#display-representations
Self::from(format!("{value:#}"))
}
}

And so there's no distinction of Rust-specific error types once they get to C

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well... you'll probably want to change that once you get to reporting reason, error_core, and error_message to OF. It's going to painful to figure these out from error strings (which are not guaranteed to be stable).

You may want to take a look at what we do in Python here: https://github.com/DataDog/dd-trace-py/pull/15098/files#diff-d2ca810369a5f55bf62d0810211bf0d40df1f74ede215ffc430486bb1cce7545. It's basically converting Result<Assignment, EvaluationFailure> to ResolutionDetails which is very similar to what OF expects + a couple of extra fields that we need.

It might even be a good idea to move ResolutionDetails into datadog-ffe, so we can share that code between python, ruby and other SDKs

Choose a reason for hiding this comment

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

Thank you for referring me to that PR, particularly the methods you have to map the native errors to OF errors are helpful: _map_reason_to_openfeature and _map_error_code_to_openfeature. We'll update Ruby to do the same mapping.

Moving ResolutionDetails into datadog-ffe doesn't sound like a bad idea. If the OF specs for python, ruby, and other SDKs never drift, that would be ideal. But even if one of them diverges, I imagine we could just augment the code for that specific SDK

@avara1986
Copy link
Member

LGTM. Those changes work fine in dd-trace-py and system-tests 👍 ✔️
DataDog/dd-trace-py#15098
DataDog/system-tests#5642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants