Skip to content

[crashtracker] Prevent crashtracker from deadlocking #1111

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 2 commits into
base: main
Choose a base branch
from

Conversation

gleocadie
Copy link
Contributor

What does this PR do?

Prevent crashtracker from deadlocking when calling is_being_traced function.

Motivation

We got a recent report with this callstack (shorten):

(gdb) bt
#0  0x0000ffffb50ba180 in ?? () from /lib/aarch64-linux-gnu/libc.so.6
#1  0x0000ffffb50557ec in malloc () from /lib/aarch64-linux-gnu/libc.so.6
#2  0x0000ffffb38d57c8 in alloc::raw_vec::RawVecInner<A>::try_allocate_in () from /home/circleci/app/tmp/build_extension/modules/ddtrace.so
#3  0x0000ffffb2e0a614 in alloc::raw_vec::RawVecInner<alloc::alloc::Global>::with_capacity (capacity=8192) at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/alloc/src/raw_vec.rs:153
#4  alloc::raw_vec::RawVec<u8, alloc::alloc::Global>::with_capacity<u8> (capacity=8192) at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/alloc/src/raw_vec.rs:131
#5  alloc::boxed::{impl#2}::new_uninit_slice<u8> (len=8192) at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/alloc/src/boxed.rs:670
#6  0x0000ffffb2e0092c in std::io::buffered::bufreader::buffer::Buffer::with_capacity (capacity=8192) at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/io/buffered/bufreader/buffer.rs:35
#7  std::io::buffered::bufreader::BufReader<std::fs::File>::with_capacity<std::fs::File> (capacity=8192, inner=...) at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/io/buffered/bufreader.rs:103
#8  0x0000ffffb2e009d0 in std::io::buffered::bufreader::BufReader<std::fs::File>::new<std::fs::File> (inner=...) at /rustc/e71f9a9a98b0faf423844bf0ba7438f29dc27d58/library/std/src/io/buffered/bufreader.rs:74
#9  0x0000ffffb2dd77f8 in ddcommon::unix_utils::is_being_traced () at src/unix_utils.rs:192
#10 0x0000ffffb2dd7b38 in ddcommon::unix_utils::alt_fork () at src/unix_utils.rs:216
#11 0x0000ffffb268cf38 in datadog_crashtracker::collector::collector_manager::Collector::spawn (receiver=0xfffff20496e8, config=0xaaaac2cf3f40, config_str=..., metadata_str=..., sig_info=0xfffff20498d0, ucontext=0xfffff2049950) at src/collector/collector_manager.rs:31
#12 0x0000ffffb26881f0 in datadog_crashtracker::collector::crash_handler::handle_posix_signal_impl (sig_info=0xfffff20498d0, ucontext=0xfffff2049950) at src/collector/crash_handler.rs:174
#13 0x0000ffffb2687e84 in datadog_crashtracker::collector::crash_handler::handle_posix_sigaction (signum=6, sig_info=0xfffff20498d0, ucontext=0xfffff2049950) at src/collector/crash_handler.rs:95
#14 <signal handler called>
...

As you can see, an allocation is done while running in the signal handler. As shown in this case, this causes a deadlock: application gets stuck.

This happens (as seen in the callstack), BufReader::new allocates. This is done here.

To avoid that, we need a zero-heap-allocation version of this version.

@pr-commenter
Copy link

pr-commenter bot commented Jun 17, 2025

Benchmarks

Comparison

Benchmark execution time: 2025-06-17 08:10:03

Comparing candidate commit 8eb0506 in PR branch gleocadie/avoid-allocationg-in-signal-handler with baseline commit 9ae6183 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 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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.252µs 85.468µs ± 0.178µs 85.449µs ± 0.060µs 85.498µs 85.663µs 85.929µs 87.405µs 2.29% 6.935 69.544 0.21% 0.013µ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 [85.444µs; 85.493µs] or [-0.029%; +0.029%] None None None

Group 2

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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.234ms 8.253ms ± 0.010ms 8.251ms ± 0.005ms 8.258ms 8.270ms 8.287ms 8.313ms 0.75% 2.140 8.791 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.252ms; 8.254ms] or [-0.017%; +0.017%] None None None

Group 3

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
two way interface execution_time 18.326µs 26.753µs ± 10.171µs 18.543µs ± 0.173µs 36.017µs 44.709µs 50.474µs 51.641µs 178.49% 0.665 -1.070 37.92% 0.719µs 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
two way interface execution_time [25.343µs; 28.162µs] or [-5.269%; +5.269%] None None None

Group 4

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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.421µs 2.453µs ± 0.027µs 2.443µs ± 0.011µs 2.466µs 2.513µs 2.525µs 2.578µs 5.51% 1.515 2.310 1.08% 0.002µ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.450µs; 2.457µs] or [-0.150%; +0.150%] None None None

Group 5

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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.892µs 3.910µs ± 0.002µs 3.910µs ± 0.001µs 3.912µs 3.914µs 3.916µs 3.917µs 0.17% -1.745 15.188 0.06% 0.000µs 1 200
credit_card/is_card_number/ throughput 255325324.689op/s 255741479.477op/s ± 160001.548op/s 255749719.633op/s ± 94132.011op/s 255840224.485op/s 255924383.090op/s 255995203.512op/s 256955374.144op/s 0.47% 1.772 15.412 0.06% 11313.818op/s 1 200
credit_card/is_card_number/ 3782-8224-6310-005 execution_time 79.127µs 80.627µs ± 0.845µs 80.460µs ± 0.595µs 81.168µs 82.131µs 82.981µs 83.555µs 3.85% 0.678 0.208 1.05% 0.060µs 1 200
credit_card/is_card_number/ 3782-8224-6310-005 throughput 11968101.150op/s 12404064.712op/s ± 129146.390op/s 12428543.440op/s ± 91918.792op/s 12503049.609op/s 12576522.563op/s 12634221.980op/s 12637868.701op/s 1.68% -0.624 0.087 1.04% 9132.029op/s 1 200
credit_card/is_card_number/ 378282246310005 execution_time 74.353µs 74.998µs ± 0.192µs 74.976µs ± 0.107µs 75.104µs 75.322µs 75.480µs 76.043µs 1.42% 0.780 4.511 0.26% 0.014µs 1 200
credit_card/is_card_number/ 378282246310005 throughput 13150428.537op/s 13333719.466op/s ± 34138.314op/s 13337676.373op/s ± 18951.992op/s 13354868.890op/s 13377377.851op/s 13417168.355op/s 13449376.697op/s 0.84% -0.735 4.362 0.26% 2413.943op/s 1 200
credit_card/is_card_number/37828224631 execution_time 3.889µs 3.910µs ± 0.003µs 3.910µs ± 0.001µs 3.912µs 3.915µs 3.918µs 3.919µs 0.24% -1.396 14.803 0.07% 0.000µs 1 200
credit_card/is_card_number/37828224631 throughput 255151150.624op/s 255728368.064op/s ± 191673.488op/s 255755741.469op/s ± 90253.689op/s 255828979.028op/s 255927531.251op/s 256007404.861op/s 257161645.195op/s 0.55% 1.429 15.060 0.07% 13553.362op/s 1 200
credit_card/is_card_number/378282246310005 execution_time 71.610µs 72.147µs ± 0.199µs 72.144µs ± 0.118µs 72.248µs 72.460µs 72.779µs 72.947µs 1.11% 0.731 1.912 0.27% 0.014µs 1 200
credit_card/is_card_number/378282246310005 throughput 13708557.256op/s 13860716.930op/s ± 38124.293op/s 13861143.749op/s ± 22669.208op/s 13885659.597op/s 13912801.587op/s 13937250.024op/s 13964466.962op/s 0.75% -0.703 1.844 0.27% 2695.795op/s 1 200
credit_card/is_card_number/37828224631000521389798 execution_time 52.124µs 52.185µs ± 0.030µs 52.185µs ± 0.021µs 52.204µs 52.238µs 52.246µs 52.253µs 0.13% 0.167 -0.639 0.06% 0.002µs 1 200
credit_card/is_card_number/37828224631000521389798 throughput 19137620.925op/s 19162450.380op/s ± 10835.806op/s 19162512.377op/s ± 7767.938op/s 19170829.666op/s 19179893.813op/s 19183135.895op/s 19184962.826op/s 0.12% -0.165 -0.640 0.06% 766.207op/s 1 200
credit_card/is_card_number/x371413321323331 execution_time 5.690µs 5.880µs ± 0.066µs 5.890µs ± 0.037µs 5.926µs 5.992µs 6.016µs 6.033µs 2.42% -0.275 0.099 1.12% 0.005µs 1 200
credit_card/is_card_number/x371413321323331 throughput 165757473.583op/s 170086626.071op/s ± 1916875.247op/s 169768949.533op/s ± 1065314.353op/s 171340155.239op/s 173635784.706op/s 174650108.036op/s 175741849.506op/s 3.52% 0.343 0.164 1.12% 135543.549op/s 1 200
credit_card/is_card_number_no_luhn/ execution_time 3.893µs 3.911µs ± 0.002µs 3.911µs ± 0.001µs 3.912µs 3.914µs 3.916µs 3.917µs 0.18% -1.712 13.962 0.06% 0.000µs 1 200
credit_card/is_card_number_no_luhn/ throughput 255267016.087op/s 255712705.574op/s ± 158305.128op/s 255719166.152op/s ± 90237.120op/s 255805602.949op/s 255913402.385op/s 255981501.069op/s 256891540.030op/s 0.46% 1.736 14.164 0.06% 11193.863op/s 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time 64.000µs 64.284µs ± 0.087µs 64.269µs ± 0.040µs 64.316µs 64.404µs 64.699µs 64.707µs 0.68% 1.656 7.997 0.14% 0.006µs 1 200
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput 15454327.509op/s 15556087.524op/s ± 21038.855op/s 15559490.866op/s ± 9571.438op/s 15566632.147op/s 15579669.391op/s 15609734.806op/s 15625118.941op/s 0.42% -1.627 7.889 0.13% 1487.672op/s 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time 57.360µs 57.500µs ± 0.086µs 57.484µs ± 0.053µs 57.544µs 57.662µs 57.746µs 57.796µs 0.54% 0.973 0.849 0.15% 0.006µs 1 200
credit_card/is_card_number_no_luhn/ 378282246310005 throughput 17302269.859op/s 17391233.958op/s ± 26042.590op/s 17396038.053op/s ± 16131.830op/s 17410623.527op/s 17423614.488op/s 17432064.348op/s 17433863.537op/s 0.22% -0.964 0.825 0.15% 1841.489op/s 1 200
credit_card/is_card_number_no_luhn/37828224631 execution_time 3.891µs 3.911µs ± 0.003µs 3.911µs ± 0.002µs 3.913µs 3.916µs 3.918µs 3.921µs 0.24% -1.199 10.668 0.08% 0.000µs 1 200
credit_card/is_card_number_no_luhn/37828224631 throughput 255062293.254op/s 255658067.676op/s ± 193538.276op/s 255662162.002op/s ± 102799.330op/s 255768315.717op/s 255913148.784op/s 255995677.837op/s 257003780.177op/s 0.52% 1.225 10.850 0.08% 13685.223op/s 1 200
credit_card/is_card_number_no_luhn/378282246310005 execution_time 54.551µs 54.735µs ± 0.128µs 54.707µs ± 0.058µs 54.772µs 55.007µs 55.138µs 55.458µs 1.37% 1.880 5.565 0.23% 0.009µs 1 200
credit_card/is_card_number_no_luhn/378282246310005 throughput 18031718.680op/s 18269949.397op/s ± 42521.741op/s 18279099.683op/s ± 19349.284op/s 18297066.523op/s 18318329.421op/s 18331055.741op/s 18331311.714op/s 0.29% -1.852 5.388 0.23% 3006.741op/s 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time 52.116µs 52.172µs ± 0.026µs 52.170µs ± 0.019µs 52.190µs 52.218µs 52.227µs 52.250µs 0.15% 0.315 -0.439 0.05% 0.002µs 1 200
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput 19138612.899op/s 19167230.889op/s ± 9522.693op/s 19168021.989op/s ± 7017.149op/s 19174453.875op/s 19181176.649op/s 19185387.836op/s 19187936.544op/s 0.10% -0.313 -0.442 0.05% 673.356op/s 1 200
credit_card/is_card_number_no_luhn/x371413321323331 execution_time 5.695µs 5.863µs ± 0.074µs 5.864µs ± 0.049µs 5.917µs 5.989µs 6.014µs 6.034µs 2.90% -0.096 -0.533 1.26% 0.005µs 1 200
credit_card/is_card_number_no_luhn/x371413321323331 throughput 165736791.246op/s 170587228.413op/s ± 2160123.289op/s 170544000.432op/s ± 1432333.206op/s 171963380.005op/s 174583013.005op/s 175250340.224op/s 175595492.477op/s 2.96% 0.151 -0.519 1.26% 152743.783op/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.910µs; 3.911µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/ throughput [255719304.801op/s; 255763654.153op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 execution_time [80.510µs; 80.745µs] or [-0.145%; +0.145%] None None None
credit_card/is_card_number/ 3782-8224-6310-005 throughput [12386166.264op/s; 12421963.160op/s] or [-0.144%; +0.144%] None None None
credit_card/is_card_number/ 378282246310005 execution_time [74.972µs; 75.025µs] or [-0.036%; +0.036%] None None None
credit_card/is_card_number/ 378282246310005 throughput [13328988.224op/s; 13338450.708op/s] or [-0.035%; +0.035%] None None None
credit_card/is_card_number/37828224631 execution_time [3.910µs; 3.911µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/37828224631 throughput [255701803.962op/s; 255754932.166op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number/378282246310005 execution_time [72.119µs; 72.174µs] or [-0.038%; +0.038%] None None None
credit_card/is_card_number/378282246310005 throughput [13855433.270op/s; 13866000.590op/s] or [-0.038%; +0.038%] None None None
credit_card/is_card_number/37828224631000521389798 execution_time [52.181µs; 52.189µs] or [-0.008%; +0.008%] None None None
credit_card/is_card_number/37828224631000521389798 throughput [19160948.641op/s; 19163952.118op/s] or [-0.008%; +0.008%] None None None
credit_card/is_card_number/x371413321323331 execution_time [5.871µs; 5.889µs] or [-0.156%; +0.156%] None None None
credit_card/is_card_number/x371413321323331 throughput [169820965.598op/s; 170352286.545op/s] or [-0.156%; +0.156%] None None None
credit_card/is_card_number_no_luhn/ execution_time [3.910µs; 3.911µs] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/ throughput [255690766.006op/s; 255734645.143op/s] or [-0.009%; +0.009%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 execution_time [64.272µs; 64.296µs] or [-0.019%; +0.019%] None None None
credit_card/is_card_number_no_luhn/ 3782-8224-6310-005 throughput [15553171.741op/s; 15559003.307op/s] or [-0.019%; +0.019%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 execution_time [57.488µs; 57.512µs] or [-0.021%; +0.021%] None None None
credit_card/is_card_number_no_luhn/ 378282246310005 throughput [17387624.705op/s; 17394843.210op/s] or [-0.021%; +0.021%] None None None
credit_card/is_card_number_no_luhn/37828224631 execution_time [3.911µs; 3.912µs] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/37828224631 throughput [255631245.132op/s; 255684890.219op/s] or [-0.010%; +0.010%] None None None
credit_card/is_card_number_no_luhn/378282246310005 execution_time [54.717µs; 54.753µs] or [-0.032%; +0.032%] None None None
credit_card/is_card_number_no_luhn/378282246310005 throughput [18264056.293op/s; 18275842.502op/s] or [-0.032%; +0.032%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 execution_time [52.169µs; 52.176µs] or [-0.007%; +0.007%] None None None
credit_card/is_card_number_no_luhn/37828224631000521389798 throughput [19165911.135op/s; 19168550.642op/s] or [-0.007%; +0.007%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 execution_time [5.853µs; 5.873µs] or [-0.175%; +0.175%] None None None
credit_card/is_card_number_no_luhn/x371413321323331 throughput [170287856.100op/s; 170886600.726op/s] or [-0.175%; +0.175%] None None None

Group 6

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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 245.445ns 256.846ns ± 11.881ns 251.921ns ± 1.971ns 256.045ns 289.068ns 291.401ns 292.395ns 16.07% 1.891 2.284 4.61% 0.840ns 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 [255.200ns; 258.493ns] or [-0.641%; +0.641%] None None None

Group 7

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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.020µs 5.101µs ± 0.050µs 5.124µs ± 0.056µs 5.134µs 5.182µs 5.188µs 5.190µs 1.28% 0.032 -1.326 0.97% 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.094µs; 5.108µs] or [-0.135%; +0.135%] None None None

Group 8

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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.468µs 34.939µs ± 0.778µs 34.572µs ± 0.055µs 34.724µs 36.581µs 36.645µs 38.153µs 10.36% 1.788 1.684 2.22% 0.055µ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.831µs; 35.046µs] or [-0.309%; +0.309%] None None None

Group 9

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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 533.735µs 534.578µs ± 0.744µs 534.468µs ± 0.232µs 534.739µs 535.281µs 535.749µs 543.605µs 1.71% 9.049 106.799 0.14% 0.053µs 1 200
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput 1839572.206op/s 1870639.013op/s ± 2570.559op/s 1871018.891op/s ± 810.064op/s 1871684.624op/s 1872731.028op/s 1873308.709op/s 1873588.334op/s 0.14% -8.937 104.971 0.14% 181.766op/s 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time 380.502µs 381.051µs ± 0.284µs 381.013µs ± 0.180µs 381.208µs 381.504µs 381.938µs 382.212µs 0.31% 1.030 1.669 0.07% 0.020µs 1 200
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput 2616347.256op/s 2624323.341op/s ± 1956.871op/s 2624582.513op/s ± 1240.054op/s 2625664.818op/s 2626798.700op/s 2627419.112op/s 2628105.878op/s 0.13% -1.024 1.650 0.07% 138.372op/s 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time 189.767µs 190.274µs ± 0.601µs 190.191µs ± 0.149µs 190.354µs 190.644µs 190.957µs 195.964µs 3.04% 8.034 71.982 0.32% 0.043µs 1 200
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput 5102977.430op/s 5255641.113op/s ± 16199.482op/s 5257882.628op/s ± 4127.008op/s 5261772.508op/s 5265573.166op/s 5269265.628op/s 5269630.793op/s 0.22% -7.945 70.876 0.31% 1145.476op/s 1 200
normalization/normalize_service/normalize_service/[empty string] execution_time 37.244µs 37.457µs ± 0.073µs 37.452µs ± 0.048µs 37.505µs 37.572µs 37.610µs 37.659µs 0.55% -0.123 0.218 0.19% 0.005µs 1 200
normalization/normalize_service/normalize_service/[empty string] throughput 26554175.076op/s 26697689.494op/s ± 52173.466op/s 26700817.978op/s ± 34203.848op/s 26730364.375op/s 26787053.713op/s 26824383.033op/s 26849654.068op/s 0.56% 0.136 0.223 0.19% 3689.221op/s 1 200
normalization/normalize_service/normalize_service/test_ASCII execution_time 45.778µs 45.899µs ± 0.058µs 45.887µs ± 0.032µs 45.927µs 46.010µs 46.056µs 46.113µs 0.49% 0.804 0.793 0.13% 0.004µs 1 200
normalization/normalize_service/normalize_service/test_ASCII throughput 21685806.399op/s 21787029.995op/s ± 27441.753op/s 21792669.866op/s ± 15250.334op/s 21805841.034op/s 21824550.885op/s 21839676.773op/s 21844617.777op/s 0.24% -0.796 0.775 0.13% 1940.425op/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 [534.475µs; 534.681µs] or [-0.019%; +0.019%] None None None
normalization/normalize_service/normalize_service/A0000000000000000000000000000000000000000000000000... throughput [1870282.758op/s; 1870995.268op/s] or [-0.019%; +0.019%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて execution_time [381.011µs; 381.090µs] or [-0.010%; +0.010%] None None None
normalization/normalize_service/normalize_service/Data🐨dog🐶 繋がっ⛰てて throughput [2624052.138op/s; 2624594.545op/s] or [-0.010%; +0.010%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters execution_time [190.190µs; 190.357µs] or [-0.044%; +0.044%] None None None
normalization/normalize_service/normalize_service/Test Conversion 0f Weird !@#$%^&**() Characters throughput [5253396.020op/s; 5257886.205op/s] or [-0.043%; +0.043%] None None None
normalization/normalize_service/normalize_service/[empty string] execution_time [37.446µs; 37.467µs] or [-0.027%; +0.027%] None None None
normalization/normalize_service/normalize_service/[empty string] throughput [26690458.753op/s; 26704920.234op/s] or [-0.027%; +0.027%] None None None
normalization/normalize_service/normalize_service/test_ASCII execution_time [45.891µs; 45.907µs] or [-0.017%; +0.017%] None None None
normalization/normalize_service/normalize_service/test_ASCII throughput [21783226.832op/s; 21790833.158op/s] 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 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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.416µs 204.934µs ± 0.386µs 204.881µs ± 0.219µs 205.108µs 205.491µs 205.943µs 208.323µs 1.68% 3.736 28.343 0.19% 0.027µs 1 200
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput 4800240.583op/s 4879641.214op/s ± 9132.801op/s 4880877.244op/s ± 5225.622op/s 4885707.619op/s 4889311.666op/s 4891197.139op/s 4891975.270op/s 0.23% -3.645 27.275 0.19% 645.787op/s 1 200
normalization/normalize_name/normalize_name/bad-name execution_time 18.547µs 18.710µs ± 0.118µs 18.668µs ± 0.058µs 18.790µs 18.944µs 19.051µs 19.218µs 2.95% 1.293 1.603 0.63% 0.008µs 1 200
normalization/normalize_name/normalize_name/bad-name throughput 52034092.032op/s 53448852.882op/s ± 333040.960op/s 53566775.525op/s ± 167408.760op/s 53687598.688op/s 53796654.438op/s 53862637.412op/s 53916533.551op/s 0.65% -1.257 1.448 0.62% 23549.552op/s 1 200
normalization/normalize_name/normalize_name/good execution_time 10.800µs 10.901µs ± 0.045µs 10.899µs ± 0.034µs 10.933µs 10.977µs 11.015µs 11.041µs 1.31% 0.403 -0.130 0.41% 0.003µs 1 200
normalization/normalize_name/normalize_name/good throughput 90568062.244op/s 91737191.299op/s ± 380476.369op/s 91755424.935op/s ± 286824.964op/s 92033564.149op/s 92309033.330op/s 92424010.232op/s 92593639.736op/s 0.91% -0.382 -0.161 0.41% 26903.742op/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 [204.880µs; 204.987µs] or [-0.026%; +0.026%] None None None
normalization/normalize_name/normalize_name/Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Long-.Too-Lo... throughput [4878375.495op/s; 4880906.932op/s] or [-0.026%; +0.026%] None None None
normalization/normalize_name/normalize_name/bad-name execution_time [18.694µs; 18.726µs] or [-0.087%; +0.087%] None None None
normalization/normalize_name/normalize_name/bad-name throughput [53402696.608op/s; 53495009.156op/s] or [-0.086%; +0.086%] None None None
normalization/normalize_name/normalize_name/good execution_time [10.895µs; 10.907µs] or [-0.058%; +0.058%] None None None
normalization/normalize_name/normalize_name/good throughput [91684460.933op/s; 91789921.664op/s] or [-0.057%; +0.057%] None None None

Group 11

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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 72.811ms 73.211ms ± 1.028ms 73.120ms ± 0.075ms 73.201ms 73.420ms 73.601ms 87.543ms 19.73% 13.654 187.863 1.40% 0.073ms 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 [73.069ms; 73.354ms] or [-0.195%; +0.195%] None None None

Group 12

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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 155.043µs 155.996µs ± 0.324µs 155.980µs ± 0.143µs 156.129µs 156.498µs 156.829µs 158.283µs 1.48% 1.753 12.220 0.21% 0.023µ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 [155.951µs; 156.040µs] or [-0.029%; +0.029%] None None None

Group 13

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 8eb0506 1750147117 gleocadie/avoid-allocationg-in-signal-handler
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.246µs 3.275µs ± 1.457µs 3.043µs ± 0.027µs 3.068µs 3.694µs 14.558µs 14.914µs 390.05% 7.287 54.383 44.37% 0.103µ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.073µs; 3.476µs] or [-6.165%; +6.165%] None None None

Baseline

Omitted due to size.

@gleocadie gleocadie force-pushed the gleocadie/avoid-allocationg-in-signal-handler branch from bf4ce2c to 4a3fcbe Compare June 17, 2025 07:57
@gleocadie gleocadie force-pushed the gleocadie/avoid-allocationg-in-signal-handler branch from 4a3fcbe to 8eb0506 Compare June 17, 2025 07:58
@gleocadie gleocadie marked this pull request as ready for review June 17, 2025 07:59
@gleocadie gleocadie requested a review from a team as a code owner June 17, 2025 07:59
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 71.00%. Comparing base (9ae6183) to head (8eb0506).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1111      +/-   ##
==========================================
+ Coverage   70.97%   71.00%   +0.03%     
==========================================
  Files         336      336              
  Lines       51191    51194       +3     
==========================================
+ Hits        36332    36350      +18     
+ Misses      14859    14844      -15     
Components Coverage Δ
datadog-crashtracker 44.42% <ø> (+0.02%) ⬆️
datadog-crashtracker-ffi 6.03% <ø> (ø)
datadog-alloc 98.73% <ø> (ø)
data-pipeline 89.23% <ø> (ø)
data-pipeline-ffi 88.94% <ø> (ø)
ddcommon 78.54% <0.00%> (-0.09%) ⬇️
ddcommon-ffi 67.87% <ø> (ø)
ddtelemetry 60.15% <ø> (ø)
ddtelemetry-ffi 21.32% <ø> (ø)
dogstatsd-client 83.26% <ø> (ø)
datadog-ipc 82.58% <ø> (ø)
datadog-profiling 77.17% <ø> (ø)
datadog-profiling-ffi 62.12% <ø> (ø)
datadog-sidecar 41.18% <ø> (ø)
datdog-sidecar-ffi 2.91% <ø> (ø)
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.07% <ø> (ø)
datadog-tracer-flare 60.47% <ø> (ø)
datadog-log 76.31% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@r1viollet
Copy link
Contributor

r1viollet commented Jun 17, 2025

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so.debug 21.98 MB 21.98 MB -0% (-24 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 69.92 MB 69.92 MB +0% (+152 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 9.16 MB 9.16 MB +0% (+144 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so.debug 26.02 MB 26.02 MB -0% (-336 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 9.08 MB 9.08 MB +0% (+24 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 82.10 MB 82.10 MB -0% (-912 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 16.01 MB 16.01 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 62.65 KB 62.65 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 109.14 MB 109.14 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 583.85 MB 583.85 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 5.01 MB 5.01 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 62.65 KB 62.65 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 15.54 MB 15.54 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 28.57 MB 28.57 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 13.58 MB 13.58 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 63.60 KB 63.60 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 110.92 MB 110.92 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 574.65 MB 574.65 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 3.78 MB 3.78 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 63.60 KB 63.60 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 16.51 MB 16.51 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 26.77 MB 26.77 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 62.68 MB 62.68 MB -0% (-808 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 9.80 MB 9.80 MB +0% (+104 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so.debug 20.84 MB 20.84 MB -0% (-304 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 77.12 MB 77.12 MB +0% (+408 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 9.70 MB 9.70 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so.debug 23.96 MB 23.96 MB +0% (+160 B) 👌

Copy link
Contributor

@morrisonlevi morrisonlevi 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 assuming that the thing we want is going to fit in the first 8K of the file. Otherwise we gotta figure out how to loop or something else.

Also, is 8k too much space on the stack?

@gleocadie
Copy link
Contributor Author

gleocadie commented Jun 18, 2025

Looks good assuming that the thing we want is going to fit in the first 8K of the file. Otherwise we gotta figure out how to loop or something else.

Yeah, I did not want to make the complex more complex directly. Generally /proc/self/status is less that 4K but in some cases they can be a bit bigger. That's why I went for 8k.

Also, is 8k too much space on the stack?

maybe, it was to take care of the case where the file is big. I can make it 4k if you think it would be safer.

// This function may run in signal handler, so we should ensure that we do not allocate
// memory on the heap (ex: avoiding using BufReader for exao).
let mut file = File::open("/proc/self/status")?;
let mut buf = [0u8; 8192];
Copy link
Contributor

Choose a reason for hiding this comment

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

how long do we expect the file to be, worst case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in general it's less than 4KB, a pathological case would be 8-10KB but I've never seen such thing

Copy link
Contributor

Choose a reason for hiding this comment

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

would there be value in looping if there are still bytes left?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH I do not know, my main goal is to avoid calling malloc here as simple as I can.
going for looping would make thing more complex and we sufficient space, I feel like it won't be necessary.
WDYT ?

let data = &buf[..n];

for line in data.split(|&b| b == b'\n') {
if let Ok(line_str) = std::str::from_utf8(line) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IF this fails, should we return false, or an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The question would be what should we do on error.
Today, the semantic is:

  • Ok(true) : use CLONE_PTRACE as an extra-flags
  • Ok(false): use 0 to specify no clone flags

Should an error have the same behavior as Ok(false) or should be stop and no crash report is generated ?
All that said, I would say, we are fine today :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I would continue. Best effort is all we can do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so keep it like that

@bwoebi
Copy link
Contributor

bwoebi commented Jul 14, 2025

Is there a specific reason this hasn't been merged yet? @gleocadie

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.

6 participants