Skip to content

Update TruncateUTF8 to never split a code point and improve perf#8836

Merged
andrewlock merged 1 commit into
masterfrom
andrew/truncate-utf-8-improvements
Jun 30, 2026
Merged

Update TruncateUTF8 to never split a code point and improve perf#8836
andrewlock merged 1 commit into
masterfrom
andrew/truncate-utf-8-improvements

Conversation

@andrewlock

@andrewlock andrewlock commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary of changes

Improves the TraceUtil.TruncateUTF8() method performance and correctness

Reason for change

The previous version would iterate over every character in a string to work out where to chop a UTF-8 string to keep the UTF-8 size the same. This is relatively slow, misses some fast-path cases, and also fails on a "correctness" level in that it could generate incorrect utf8 bytes if it split a surrogate pair.

Implementation details

  • Handle fast paths for length (e.g. if length > limit / 3 then we know we're fine)
  • Only call Encoding.GetByteCount(value) on the whole string if there's a chance it might be in range
  • Use a binary search to find where to make the cut
    • On .NET Core we can use the Span<T> overloads to remove allocation
    • On .NET Framework we make a single copy (up to size limit) so that we can check the size of sub segments
  • Backtrack on the final cut to handle split surrogate pairs

Note that we don't handle split combining-mark / grapheme-cluster, because the agent doesn't handle those either. It makes our life simpler, and is a rare edge case, for an already oversized string

Test coverage

Tweaked existing unit test to demonstrate the split surrogate issue, and added some extra unit tests.

Ran various benchmarks comparing the old to new - the new version is faster in all cases, and in some cases allocates much less 🎉

Method Runtime Scenario Mean Allocated
Original .NET 10.0 ShortAscii 2.8301 ns -
Current .NET 10.0 ShortAscii 0.2683 ns -
Original .NET 6.0 ShortAscii 3.4347 ns -
Current .NET 6.0 ShortAscii 0.2441 ns -
Original .NET Framework 4.7.2 ShortAscii 6.5876 ns -
Current .NET Framework 4.7.2 ShortAscii 0.2579 ns -
Original .NET 10.0 AsciiAtLimit 5.4113 ns -
Current .NET 10.0 AsciiAtLimit 4.6095 ns -
Original .NET 6.0 AsciiAtLimit 7.3724 ns -
Current .NET 6.0 AsciiAtLimit 7.1666 ns -
Original .NET Framework 4.7.2 AsciiAtLimit 25.2299 ns -
Current .NET Framework 4.7.2 AsciiAtLimit 25.1155 ns -
Original .NET 10.0 AsciiJustOver 472.1849 ns -
Current .NET 10.0 AsciiJustOver 67.7282 ns 424 B
Original .NET 6.0 AsciiJustOver 873.6068 ns 456 B
Current .NET 6.0 AsciiJustOver 73.7649 ns 424 B
Original .NET Framework 4.7.2 AsciiJustOver 780.5378 ns 465 B
Current .NET Framework 4.7.2 AsciiJustOver 237.3104 ns 433 B
Original .NET 10.0 LongAsciiResource 12,202.0970 ns 10056 B
Current .NET 10.0 LongAsciiResource 1,241.6327 ns 10024 B
Original .NET 6.0 LongAsciiResource 21,344.1692 ns 10056 B
Current .NET 6.0 LongAsciiResource 1,367.5132 ns 10024 B
Original .NET Framework 4.7.2 LongAsciiResource 28,561.6945 ns 10095 B
Current .NET Framework 4.7.2 LongAsciiResource 6,330.6863 ns 10056 B
Original .NET 10.0 Emoji 36,750.6962 ns 190096 B
Current .NET 10.0 Emoji 4,626.4329 ns 5808 B
Original .NET 6.0 Emoji 50,897.8086 ns 190096 B
Current .NET 6.0 Emoji 4,658.5506 ns 5808 B
Original .NET Framework 4.7.2 Emoji 45,684.4763 ns 163906 B
Current .NET Framework 4.7.2 Emoji 25,695.7428 ns 5724 B
Original .NET 10.0 TwoByte 9,284.9370 ns 33336 B
Current .NET 10.0 TwoByte 2,223.1208 ns 5024 B
Original .NET 6.0 TwoByte 13,769.0937 ns 5056 B
Current .NET 6.0 TwoByte 2,635.3342 ns 5024 B
Original .NET Framework 4.7.2 TwoByte 11,619.9163 ns 5082 B
Current .NET Framework 4.7.2 TwoByte 7,858.6355 ns 5049 B
Benchmark Details

// <copyright file="TruncateUtf8Benchmark.cs" company="Datadog">
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
// </copyright>

#nullable enable

using System;
using System.Buffers;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using BenchmarkDotNet.Attributes;

namespace Benchmarks.Trace;

/// <summary>
/// Compares the current <c>TraceUtil.TruncateUTF8</c> implementation against the original (pre-rewrite)
/// per-char implementation, across the common inputs plus a couple of edge cases. Both are reproduced
/// inline so the comparison can be re-run independently of the production code.
///  - <see cref="Original"/> : the pre-branch implementation (full byte count, then a per-char loop).
///  - <see cref="Current"/>  : the shipped implementation (length-bounds fast path + count-based binary
///                             search; span on .NET Core, pooled char[] on .NET Framework).
/// </summary>
[MemoryDiagnoser]
[BenchmarkCategory(Constants.TracerCategory, Constants.RunOnPrs, Constants.RunOnMaster)]
public class TruncateUtf8Benchmark
{
    private static readonly UTF8Encoding Encoding = new UTF8Encoding(false);

    // Built once; referenced by the scenarios below.
    private static readonly string ShortAscii = new string('a', 20);
    private static readonly string AsciiAtLimit = new string('a', 200);
    private static readonly string AsciiJustOverLimit = new string('a', 250);
    private static readonly string LongAsciiResource = new string('a', 100_000);
    private static readonly string TwoByteOverLimit = new string('é', 4000); // é (precomposed) = 2 UTF-8 bytes
    private static readonly string EmojiOverLimit = Repeat("\U0001F600", 2000);  // 😀 = 2 chars / 4 bytes

    [ParamsSource(nameof(Scenarios))]
    public TruncateScenario? Scenario { get; set; }

    public static IEnumerable<TruncateScenario> Scenarios()
    {
        // Limits mirror real call sites: 200 (meta/metric keys), 5000 (resource / meta value).

        // Common cases.
        yield return new TruncateScenario("ShortAscii_NoTruncate", ShortAscii, 200);
        yield return new TruncateScenario("AsciiAtLimit_NoTruncate", AsciiAtLimit, 200);
        yield return new TruncateScenario("AsciiJustOver", AsciiJustOverLimit, 200);
        yield return new TruncateScenario("TwoByte", TwoByteOverLimit, 5000);

        // Edge cases.
        yield return new TruncateScenario("LongAsciiResource_Degenerate", LongAsciiResource, 5000);
        yield return new TruncateScenario("Emoji", EmojiOverLimit, 5000);
    }

    [Benchmark(Baseline = true)]
    public string Original()
    {
        var value = Scenario!.Value;
        OriginalImpl(ref value, Scenario.Limit);
        return value;
    }

    [Benchmark]
    public string Current()
    {
        var value = Scenario!.Value;
        CurrentImpl(ref value, Scenario.Limit);
        return value;
    }

    private static string Repeat(string unit, int count)
    {
        var sb = new StringBuilder(unit.Length * count);
        for (var i = 0; i < count; i++)
        {
            sb.Append(unit);
        }

        return sb.ToString();
    }

    // ---- Candidate implementations -------------------------------------------------------------

    // The pre-branch implementation: full byte count, then a per-char GetByteCount loop.
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private static bool OriginalImpl(ref string value, int limit)
    {
        if (string.IsNullOrEmpty(value) || Encoding.GetByteCount(value) <= limit)
        {
            return false;
        }

        var charArray = new char[1];
        var length = 0;
        for (var i = 0; i < value.Length - 1; i++)
        {
            charArray[0] = value[i];
            length += Encoding.GetByteCount(charArray, 0, 1);
            if (length > limit)
            {
                value = value.Substring(0, i);
                return true;
            }
        }

        return false;
    }

    // The shipped implementation, copied from TraceUtil.TruncateUTF8.
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    private static bool CurrentImpl(ref string value, int limit)
    {
        // Each UTF-16 char is at most 3 UTF-8 bytes, so length <= limit/3 can never exceed the byte limit.
        if (string.IsNullOrEmpty(value) || value.Length <= limit / 3)
        {
            return false;
        }

        // Each char is at least 1 byte, so length > limit guarantees we're over. We only count when
        // length <= limit, so GetByteCount scans at most `limit` chars.
        if (value.Length <= limit && Encoding.GetByteCount(value) <= limit)
        {
            return false;
        }

        value = CurrentSlow(value, limit);
        return true;

        static string CurrentSlow(string value, int limit)
        {
            // Find the largest prefix whose UTF-8 byte count is <= limit by counting only. Seed lo at
            // limit/3 (a limit/3-char prefix always fits) and cap hi at limit (the cut can't exceed limit chars).
            var lo = limit / 3;
            var hi = Math.Min(value.Length, limit);
#if NETCOREAPP
            while (lo < hi)
            {
                var mid = lo + ((hi - lo + 1) >> 1);
                if (Encoding.GetByteCount(value.AsSpan(0, mid)) <= limit)
                {
                    lo = mid;
                }
                else
                {
                    hi = mid - 1;
                }
            }
#else
            var buffer = ArrayPool<char>.Shared.Rent(hi);
            try
            {
                value.CopyTo(0, buffer, 0, hi);
                while (lo < hi)
                {
                    var mid = lo + ((hi - lo + 1) >> 1);
                    if (Encoding.GetByteCount(buffer, 0, mid) <= limit)
                    {
                        lo = mid;
                    }
                    else
                    {
                        hi = mid - 1;
                    }
                }
            }
            finally
            {
                ArrayPool<char>.Shared.Return(buffer);
            }
#endif
            var cut = lo;

            // Drop a trailing lone high surrogate so the cut lands on a code-point boundary.
            if (cut > 0 && char.IsHighSurrogate(value[cut - 1]))
            {
                cut--;
            }

            return value.Substring(0, cut);
        }
    }

    public class TruncateScenario
    {
        public TruncateScenario(string name, string value, int limit)
        {
            Name = name;
            Value = value;
            Limit = limit;
        }

        public string Name { get; }

        public string Value { get; }

        public int Limit { get; }

        public override string ToString() => Name;
    }
}

Other details

I explored some other approaches too, e.g. using fixed to avoid the need for the array pool, but I preferred this approach for simplicity.

The old per-char loop mis-counted surrogate pairs and could Substring between a high/low surrogate, producing invalid UTF-8.

This rewrites to an allocation-free (on .NET Core, .NET FX uses array pool) slow path: binary-search the byte boundary, then walk back partial surrogate pairs. Adds additional fast-path cases too.
@andrewlock
andrewlock requested a review from a team as a code owner June 26, 2026 16:02
@andrewlock andrewlock added area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:performance Performance, speed, latency, resource usage (CPU, memory) area:client-side-stats labels Jun 26, 2026
@andrewlock andrewlock changed the title UpdateTruncateUTF8 to never split a code point and improve perf Update TruncateUTF8 to never split a code point and improve perf Jun 26, 2026
@dd-trace-dotnet-ci-bot

Copy link
Copy Markdown

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing This PR (8836) and master.

✅ No regressions detected - check the details below

Full Metrics Comparison

FakeDbCommand

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration70.23 ± (70.21 - 70.48) ms70.19 ± (70.13 - 70.39) ms-0.1%
.NET Framework 4.8 - Bailout
duration74.00 ± (73.83 - 74.16) ms74.41 ± (74.29 - 74.63) ms+0.5%✅⬆️
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1080.33 ± (1079.51 - 1086.25) ms1079.81 ± (1080.26 - 1087.46) ms-0.0%
.NET Core 3.1 - Baseline
process.internal_duration_ms22.06 ± (22.02 - 22.09) ms22.08 ± (22.05 - 22.10) ms+0.1%✅⬆️
process.time_to_main_ms80.64 ± (80.49 - 80.78) ms81.05 ± (80.89 - 81.22) ms+0.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.91 ± (10.90 - 10.91) MB10.93 ± (10.92 - 10.93) MB+0.2%✅⬆️
runtime.dotnet.threads.count12 ± (12 - 12)12 ± (12 - 12)+0.0%
.NET Core 3.1 - Bailout
process.internal_duration_ms21.97 ± (21.94 - 22.00) ms22.02 ± (21.99 - 22.05) ms+0.2%✅⬆️
process.time_to_main_ms81.99 ± (81.84 - 82.14) ms82.06 ± (81.92 - 82.19) ms+0.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.96 ± (10.95 - 10.96) MB10.96 ± (10.96 - 10.97) MB+0.1%✅⬆️
runtime.dotnet.threads.count13 ± (13 - 13)13 ± (13 - 13)+0.0%
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms210.47 ± (209.62 - 211.33) ms210.24 ± (209.44 - 211.04) ms-0.1%
process.time_to_main_ms527.83 ± (526.54 - 529.11) ms532.88 ± (531.58 - 534.18) ms+1.0%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed48.66 ± (48.63 - 48.70) MB48.83 ± (48.80 - 48.86) MB+0.3%✅⬆️
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)+0.5%✅⬆️
.NET 6 - Baseline
process.internal_duration_ms20.87 ± (20.84 - 20.90) ms20.89 ± (20.86 - 20.92) ms+0.1%✅⬆️
process.time_to_main_ms69.76 ± (69.64 - 69.87) ms70.33 ± (70.20 - 70.45) ms+0.8%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.62 ± (10.62 - 10.63) MB10.64 ± (10.64 - 10.64) MB+0.2%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 6 - Bailout
process.internal_duration_ms21.08 ± (21.05 - 21.12) ms20.75 ± (20.72 - 20.79) ms-1.5%
process.time_to_main_ms72.75 ± (72.51 - 72.98) ms71.15 ± (71.02 - 71.28) ms-2.2%
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed10.74 ± (10.74 - 10.74) MB10.76 ± (10.76 - 10.77) MB+0.2%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms368.47 ± (366.17 - 370.77) ms373.35 ± (371.33 - 375.37) ms+1.3%✅⬆️
process.time_to_main_ms534.88 ± (533.75 - 536.01) ms536.46 ± (535.10 - 537.83) ms+0.3%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed50.17 ± (50.15 - 50.19) MB50.13 ± (50.11 - 50.16) MB-0.1%
runtime.dotnet.threads.count28 ± (28 - 28)28 ± (28 - 28)-0.4%
.NET 8 - Baseline
process.internal_duration_ms19.19 ± (19.15 - 19.23) ms19.40 ± (19.36 - 19.44) ms+1.1%✅⬆️
process.time_to_main_ms70.95 ± (70.64 - 71.25) ms72.74 ± (72.48 - 72.99) ms+2.5%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.67 ± (7.66 - 7.67) MB7.69 ± (7.68 - 7.69) MB+0.2%✅⬆️
runtime.dotnet.threads.count10 ± (10 - 10)10 ± (10 - 10)+0.0%
.NET 8 - Bailout
process.internal_duration_ms18.99 ± (18.96 - 19.01) ms19.15 ± (19.12 - 19.18) ms+0.9%✅⬆️
process.time_to_main_ms70.44 ± (70.32 - 70.55) ms71.23 ± (71.04 - 71.43) ms+1.1%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed7.72 ± (7.71 - 7.73) MB7.75 ± (7.74 - 7.76) MB+0.4%✅⬆️
runtime.dotnet.threads.count11 ± (11 - 11)11 ± (11 - 11)+0.0%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms296.29 ± (293.29 - 299.30) ms300.05 ± (297.83 - 302.26) ms+1.3%✅⬆️
process.time_to_main_ms482.48 ± (481.21 - 483.76) ms483.32 ± (482.32 - 484.33) ms+0.2%✅⬆️
runtime.dotnet.exceptions.count0 ± (0 - 0)0 ± (0 - 0)+0.0%
runtime.dotnet.mem.committed37.10 ± (37.06 - 37.14) MB37.21 ± (37.18 - 37.24) MB+0.3%✅⬆️
runtime.dotnet.threads.count27 ± (27 - 27)27 ± (27 - 27)+0.1%✅⬆️

HttpMessageHandler

Metric Master (Mean ± 95% CI) Current (Mean ± 95% CI) Change Status
.NET Framework 4.8 - Baseline
duration204.32 ± (203.71 - 204.79) ms203.07 ± (202.88 - 203.75) ms-0.6%
.NET Framework 4.8 - Bailout
duration207.15 ± (206.65 - 207.66) ms206.12 ± (205.93 - 206.46) ms-0.5%
.NET Framework 4.8 - CallTarget+Inlining+NGEN
duration1211.22 ± (1210.12 - 1216.27) ms1204.05 ± (1204.43 - 1210.62) ms-0.6%
.NET Core 3.1 - Baseline
process.internal_duration_ms197.94 ± (197.53 - 198.35) ms195.62 ± (195.24 - 195.99) ms-1.2%
process.time_to_main_ms85.95 ± (85.69 - 86.20) ms85.24 ± (84.96 - 85.52) ms-0.8%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.03 ± (16.01 - 16.06) MB16.05 ± (16.03 - 16.07) MB+0.1%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (19 - 20)-0.1%
.NET Core 3.1 - Bailout
process.internal_duration_ms197.22 ± (196.82 - 197.62) ms196.24 ± (195.70 - 196.78) ms-0.5%
process.time_to_main_ms87.51 ± (87.32 - 87.71) ms85.98 ± (85.72 - 86.23) ms-1.8%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed16.04 ± (16.02 - 16.07) MB16.06 ± (16.04 - 16.08) MB+0.1%✅⬆️
runtime.dotnet.threads.count21 ± (21 - 21)21 ± (21 - 21)+0.7%✅⬆️
.NET Core 3.1 - CallTarget+Inlining+NGEN
process.internal_duration_ms391.66 ± (390.34 - 392.98) ms392.36 ± (391.27 - 393.44) ms+0.2%✅⬆️
process.time_to_main_ms547.70 ± (546.23 - 549.17) ms545.12 ± (543.80 - 546.43) ms-0.5%
runtime.dotnet.exceptions.count3 ± (3 - 3)3 ± (3 - 3)+0.0%
runtime.dotnet.mem.committed58.51 ± (58.28 - 58.74) MB58.48 ± (58.25 - 58.70) MB-0.1%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)-0.5%
.NET 6 - Baseline
process.internal_duration_ms203.31 ± (202.90 - 203.73) ms200.06 ± (199.69 - 200.43) ms-1.6%
process.time_to_main_ms75.39 ± (75.14 - 75.65) ms73.84 ± (73.59 - 74.08) ms-2.1%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.33 ± (16.31 - 16.35) MB16.45 ± (16.41 - 16.48) MB+0.7%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)+0.9%✅⬆️
.NET 6 - Bailout
process.internal_duration_ms202.39 ± (202.11 - 202.67) ms198.79 ± (198.41 - 199.18) ms-1.8%
process.time_to_main_ms76.06 ± (75.89 - 76.23) ms74.61 ± (74.38 - 74.84) ms-1.9%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed16.35 ± (16.33 - 16.38) MB16.44 ± (16.41 - 16.47) MB+0.5%✅⬆️
runtime.dotnet.threads.count20 ± (20 - 20)20 ± (20 - 20)-0.8%
.NET 6 - CallTarget+Inlining+NGEN
process.internal_duration_ms583.44 ± (580.73 - 586.15) ms589.64 ± (587.21 - 592.07) ms+1.1%✅⬆️
process.time_to_main_ms555.09 ± (554.14 - 556.05) ms550.64 ± (549.60 - 551.69) ms-0.8%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed61.37 ± (61.29 - 61.45) MB61.58 ± (61.47 - 61.68) MB+0.3%✅⬆️
runtime.dotnet.threads.count31 ± (31 - 31)31 ± (31 - 31)+0.2%✅⬆️
.NET 8 - Baseline
process.internal_duration_ms198.39 ± (197.97 - 198.81) ms196.69 ± (196.34 - 197.04) ms-0.9%
process.time_to_main_ms73.05 ± (72.76 - 73.34) ms72.63 ± (72.33 - 72.92) ms-0.6%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.69 ± (11.67 - 11.70) MB11.74 ± (11.72 - 11.76) MB+0.5%✅⬆️
runtime.dotnet.threads.count19 ± (18 - 19)18 ± (18 - 18)-2.0%
.NET 8 - Bailout
process.internal_duration_ms198.31 ± (197.85 - 198.77) ms197.36 ± (196.90 - 197.82) ms-0.5%
process.time_to_main_ms74.23 ± (73.99 - 74.47) ms74.27 ± (74.06 - 74.47) ms+0.0%✅⬆️
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed11.69 ± (11.67 - 11.71) MB11.78 ± (11.76 - 11.80) MB+0.7%✅⬆️
runtime.dotnet.threads.count19 ± (19 - 19)19 ± (19 - 19)-0.1%
.NET 8 - CallTarget+Inlining+NGEN
process.internal_duration_ms511.12 ± (508.28 - 513.97) ms514.29 ± (511.32 - 517.25) ms+0.6%✅⬆️
process.time_to_main_ms501.87 ± (501.00 - 502.75) ms497.97 ± (497.17 - 498.77) ms-0.8%
runtime.dotnet.exceptions.count4 ± (4 - 4)4 ± (4 - 4)+0.0%
runtime.dotnet.mem.committed50.94 ± (50.90 - 50.98) MB50.93 ± (50.90 - 50.97) MB-0.0%
runtime.dotnet.threads.count30 ± (30 - 30)30 ± (30 - 30)+0.3%✅⬆️
Comparison explanation

Execution-time benchmarks measure the whole time it takes to execute a program, and are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are highlighted in **red**. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

Duration charts
FakeDbCommand (.NET Framework 4.8)
gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8836) - mean (70ms)  : 69, 72
    master - mean (70ms)  : 69, 72

    section Bailout
    This PR (8836) - mean (74ms)  : 73, 76
    master - mean (74ms)  : 72, 76

    section CallTarget+Inlining+NGEN
    This PR (8836) - mean (1,084ms)  : 1032, 1135
    master - mean (1,083ms)  : 1035, 1131

Loading
FakeDbCommand (.NET Core 3.1)
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8836) - mean (110ms)  : 107, 113
    master - mean (109ms)  : 106, 112

    section Bailout
    This PR (8836) - mean (110ms)  : 108, 113
    master - mean (110ms)  : 108, 112

    section CallTarget+Inlining+NGEN
    This PR (8836) - mean (782ms)  : 757, 807
    master - mean (774ms)  : 753, 795

Loading
FakeDbCommand (.NET 6)
gantt
    title Execution time (ms) FakeDbCommand (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8836) - mean (97ms)  : 95, 99
    master - mean (96ms)  : 93, 99

    section Bailout
    This PR (8836) - mean (98ms)  : 96, 99
    master - mean (101ms)  : 95, 106

    section CallTarget+Inlining+NGEN
    This PR (8836) - mean (945ms)  : 909, 981
    master - mean (935ms)  : 889, 980

Loading
FakeDbCommand (.NET 8)
gantt
    title Execution time (ms) FakeDbCommand (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8836) - mean (100ms)  : 94, 105
    master - mean (97ms)  : 91, 104

    section Bailout
    This PR (8836) - mean (98ms)  : 92, 103
    master - mean (96ms)  : 94, 97

    section CallTarget+Inlining+NGEN
    This PR (8836) - mean (813ms)  : 777, 848
    master - mean (812ms)  : 765, 859

Loading
HttpMessageHandler (.NET Framework 4.8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8836) - mean (203ms)  : 199, 208
    master - mean (204ms)  : 197, 211

    section Bailout
    This PR (8836) - mean (206ms)  : 204, 209
    master - mean (207ms)  : 202, 212

    section CallTarget+Inlining+NGEN
    This PR (8836) - mean (1,208ms)  : 1165, 1250
    master - mean (1,213ms)  : 1168, 1258

Loading
HttpMessageHandler (.NET Core 3.1)
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8836) - mean (291ms)  : 285, 296
    master - mean (294ms)  : 288, 301

    section Bailout
    This PR (8836) - mean (293ms)  : 286, 299
    master - mean (295ms)  : 289, 300

    section CallTarget+Inlining+NGEN
    This PR (8836) - mean (980ms)  : 952, 1007
    master - mean (983ms)  : 962, 1003

Loading
HttpMessageHandler (.NET 6)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8836) - mean (283ms)  : 278, 288
    master - mean (289ms)  : 283, 294

    section Bailout
    This PR (8836) - mean (282ms)  : 277, 288
    master - mean (288ms)  : 283, 292

    section CallTarget+Inlining+NGEN
    This PR (8836) - mean (1,172ms)  : 1127, 1216
    master - mean (1,171ms)  : 1132, 1211

Loading
HttpMessageHandler (.NET 8)
gantt
    title Execution time (ms) HttpMessageHandler (.NET 8)
    dateFormat  x
    axisFormat %Q
    todayMarker off
    section Baseline
    This PR (8836) - mean (279ms)  : 273, 286
    master - mean (282ms)  : 276, 287

    section Bailout
    This PR (8836) - mean (282ms)  : 275, 288
    master - mean (282ms)  : 276, 289

    section CallTarget+Inlining+NGEN
    This PR (8836) - mean (1,045ms)  : 1000, 1090
    master - mean (1,047ms)  : 1001, 1094

Loading

@pr-commenter

pr-commenter Bot commented Jun 26, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-06-26 16:43:55

Comparing candidate commit e694922 in PR branch andrew/truncate-utf-8-improvements with baseline commit 3349535 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 1 performance regressions! Performance is the same for 71 metrics, 0 unstable metrics, 58 known flaky benchmarks, 68 flaky benchmarks without significant changes.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:Benchmarks.Trace.HttpClientBenchmark.SendAsync net472

  • 🟥 throughput [-5407.680op/s; -5068.871op/s] or [-6.173%; -5.786%]

Known flaky benchmarks

These benchmarks are marked as flaky and will not trigger a failure. Modify FLAKY_BENCHMARKS_REGEX to control which benchmarks are marked as flaky.

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net472

  • 🟥 throughput [-6760.447op/s; -6272.955op/s] or [-8.016%; -7.438%]

scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild netcoreapp3.1

  • 🟥 throughput [-7750.843op/s; -5974.880op/s] or [-7.881%; -6.075%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • 🟥 execution_time [+311.745ms; +319.421ms] or [+154.699%; +158.508%]
  • 🟥 throughput [-44.137op/s; -40.283op/s] or [-7.941%; -7.248%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • 🟥 execution_time [+379.119ms; +380.520ms] or [+299.527%; +300.634%]
  • 🟩 throughput [+93.450op/s; +95.862op/s] or [+12.321%; +12.639%]

scenario:Benchmarks.Trace.AgentWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 execution_time [+389.672ms; +392.654ms] or [+344.845%; +347.483%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net472

  • 🟥 allocated_mem [+1.308KB; +1.308KB] or [+27.528%; +27.540%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody net6.0

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+9.976%; +9.987%]
  • 🟩 execution_time [-15.885ms; -11.691ms] or [-7.419%; -5.460%]
  • 🟩 throughput [+7597.119op/s; +10365.189op/s] or [+5.545%; +7.566%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleMoreComplexBody netcoreapp3.1

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+27.500%; +27.510%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net472

  • 🟥 allocated_mem [+1.307KB; +1.307KB] or [+105.743%; +105.758%]
  • 🟥 throughput [-270934.097op/s; -267424.085op/s] or [-27.664%; -27.305%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody net6.0

  • 🟥 allocated_mem [+471 bytes; +472 bytes] or [+38.557%; +38.566%]
  • 🟩 execution_time [-26.435ms; -21.586ms] or [-11.789%; -9.626%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.AllCycleSimpleBody netcoreapp3.1

  • 🟥 allocated_mem [+1.272KB; +1.272KB] or [+105.288%; +105.304%]
  • 🟥 throughput [-148261.269op/s; -132177.025op/s] or [-21.302%; -18.991%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody netcoreapp3.1

  • 🟩 throughput [+8720.908op/s; +11356.292op/s] or [+6.947%; +9.047%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net6.0

  • 🟩 throughput [+465712.820op/s; +486946.671op/s] or [+15.529%; +16.237%]

scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody netcoreapp3.1

  • 🟩 execution_time [-19.089ms; -14.566ms] or [-8.799%; -6.714%]
  • 🟩 throughput [+170762.200op/s; +227865.293op/s] or [+6.778%; +9.045%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net472

  • 🟥 execution_time [+299.392ms; +300.177ms] or [+149.596%; +149.988%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs net6.0

  • 🟥 execution_time [+299.133ms; +302.303ms] or [+150.853%; +152.452%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeArgs netcoreapp3.1

  • 🟥 execution_time [+299.342ms; +301.727ms] or [+150.785%; +151.986%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net472

  • 🟥 execution_time [+296.070ms; +296.804ms] or [+145.418%; +145.778%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs net6.0

  • 🟥 execution_time [+295.110ms; +297.625ms] or [+144.268%; +145.498%]

scenario:Benchmarks.Trace.Asm.AppSecEncoderBenchmark.EncodeLegacyArgs netcoreapp3.1

  • 🟥 execution_time [+299.496ms; +300.701ms] or [+149.688%; +150.290%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net6.0

  • 🟥 execution_time [+24.428µs; +51.885µs] or [+5.603%; +11.900%]
  • 🟥 throughput [-251.379op/s; -128.009op/s] or [-10.929%; -5.565%]

scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net6.0

  • 🟥 execution_time [+34.257µs; +58.708µs] or [+10.937%; +18.742%]
  • 🟥 throughput [-527.132op/s; -322.683op/s] or [-16.432%; -10.059%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net472

  • 🟥 execution_time [+299.788ms; +300.623ms] or [+149.625%; +150.042%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest net6.0

  • 🟥 execution_time [+410.068ms; +417.975ms] or [+445.556%; +454.148%]
  • 🟩 throughput [+725.172op/s; +909.030op/s] or [+5.959%; +7.470%]

scenario:Benchmarks.Trace.AspNetCoreBenchmark.SendRequest netcoreapp3.1

  • unstable execution_time [+248.485ms; +312.012ms] or [+188.673%; +236.908%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net472

  • unstable execution_time [+358.553ms; +448.659ms] or [+164.859%; +206.289%]
  • 🟥 throughput [-602.115op/s; -543.976op/s] or [-54.558%; -49.290%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces net6.0

  • unstable execution_time [+211.457ms; +344.671ms] or [+90.114%; +146.884%]
  • 🟥 throughput [-667.158op/s; -583.671op/s] or [-44.500%; -38.931%]

scenario:Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark.WriteAndFlushEnrichedTraces netcoreapp3.1

  • 🟥 execution_time [+344.492ms; +359.419ms] or [+206.046%; +214.974%]
  • 🟥 throughput [-419.958op/s; -379.146op/s] or [-29.241%; -26.399%]

scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net6.0

  • 🟩 execution_time [-187.988µs; -156.797µs] or [-9.523%; -7.943%]
  • 🟩 throughput [+44.674op/s; +53.196op/s] or [+8.819%; +10.501%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net472

  • 🟥 execution_time [+304.346ms; +306.634ms] or [+153.263%; +154.415%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch net6.0

  • 🟥 execution_time [+300.502ms; +302.451ms] or [+150.582%; +151.559%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearch netcoreapp3.1

  • 🟥 execution_time [+304.184ms; +307.785ms] or [+152.809%; +154.618%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net472

  • 🟥 execution_time [+299.427ms; +303.276ms] or [+150.362%; +152.295%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync net6.0

  • 🟥 execution_time [+300.098ms; +302.146ms] or [+148.385%; +149.398%]

scenario:Benchmarks.Trace.ElasticsearchBenchmark.CallElasticsearchAsync netcoreapp3.1

  • 🟥 execution_time [+302.207ms; +306.365ms] or [+153.172%; +155.279%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net472

  • 🟥 execution_time [+300.118ms; +302.953ms] or [+150.632%; +152.055%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync net6.0

  • 🟥 execution_time [+302.253ms; +304.840ms] or [+150.646%; +151.935%]
  • 🟩 throughput [+48187.130op/s; +52161.251op/s] or [+9.568%; +10.358%]

scenario:Benchmarks.Trace.GraphQLBenchmark.ExecuteAsync netcoreapp3.1

  • 🟥 execution_time [+303.359ms; +306.293ms] or [+150.918%; +152.378%]

scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net6.0

  • 🟩 execution_time [-17.045ms; -13.381ms] or [-7.926%; -6.222%]
  • 🟩 throughput [+20696.316op/s; +27595.527op/s] or [+5.678%; +7.570%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net472

  • unstable execution_time [+9.774µs; +53.545µs] or [+2.414%; +13.226%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark net6.0

  • 🟩 allocated_mem [-19.068KB; -19.045KB] or [-6.955%; -6.947%]
  • unstable execution_time [-31.694µs; +25.641µs] or [-6.264%; +5.068%]
  • unstable throughput [-91.882op/s; +109.531op/s] or [-4.585%; +5.466%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark netcoreapp3.1

  • unstable execution_time [-27.122µs; +40.149µs] or [-4.700%; +6.958%]
  • unstable throughput [-100.038op/s; +85.312op/s] or [-5.715%; +4.874%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net6.0

  • unstable execution_time [+6.857µs; +11.882µs] or [+16.208%; +28.085%]
  • 🟥 throughput [-5135.198op/s; -3197.786op/s] or [-21.618%; -13.462%]

scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark netcoreapp3.1

  • unstable execution_time [-13.097µs; -5.485µs] or [-20.320%; -8.510%]
  • unstable throughput [+1245.492op/s; +2892.925op/s] or [+7.642%; +17.749%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net472

  • 🟥 execution_time [+302.880ms; +304.397ms] or [+153.092%; +153.859%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog net6.0

  • 🟥 execution_time [+303.917ms; +306.875ms] or [+154.693%; +156.198%]

scenario:Benchmarks.Trace.Log4netBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+299.774ms; +303.236ms] or [+150.074%; +151.807%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net472

  • 🟥 execution_time [+299.113ms; +301.128ms] or [+149.081%; +150.085%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog net6.0

  • unstable execution_time [+297.621ms; +324.104ms] or [+149.451%; +162.749%]

scenario:Benchmarks.Trace.SerilogBenchmark.EnrichedLog netcoreapp3.1

  • 🟥 execution_time [+302.053ms; +304.986ms] or [+153.182%; +154.669%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net472

  • 🟥 execution_time [+300.275ms; +301.105ms] or [+149.779%; +150.193%]
  • 🟩 throughput [+65892681.840op/s; +66232253.110op/s] or [+47.987%; +48.234%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore net6.0

  • 🟥 execution_time [+423.163ms; +428.654ms] or [+526.278%; +533.107%]

scenario:Benchmarks.Trace.SingleSpanAspNetCoreBenchmark.SingleSpanAspNetCore netcoreapp3.1

  • 🟥 execution_time [+299.338ms; +300.435ms] or [+149.303%; +149.850%]
  • 🟩 throughput [+18133210.300op/s; +19106997.593op/s] or [+8.032%; +8.463%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net6.0

  • 🟩 throughput [+69452.502op/s; +81350.478op/s] or [+6.485%; +7.595%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope netcoreapp3.1

  • 🟩 throughput [+64202.609op/s; +83338.019op/s] or [+7.431%; +9.646%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan netcoreapp3.1

  • 🟩 throughput [+85119.464op/s; +94745.345op/s] or [+8.454%; +9.410%]

scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net6.0

  • 🟩 throughput [+47156.509op/s; +51061.866op/s] or [+8.563%; +9.272%]

scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net6.0

  • 🟩 throughput [+75471.551op/s; +95358.488op/s] or [+8.432%; +10.654%]

Known flaky benchmarks without significant changes:

  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.ActivityBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_AddEvent_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_GetContext_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_RecordException_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetAttributes_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_SetStatus_Sampled netcoreapp3.1
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net472
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled net6.0
  • scenario:Benchmarks.OpenTelemetry.InstrumentedApi.Trace.TelemetrySpanBenchmark.StartSpan_UpdateName_Sampled netcoreapp3.1
  • scenario:Benchmarks.Trace.ActivityBenchmark.StartStopWithChild net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody net6.0
  • scenario:Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorSimpleBody net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmark netcoreapp3.1
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack net472
  • scenario:Benchmarks.Trace.Asm.AppSecWafBenchmark.RunWafRealisticBenchmarkWithAttack netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool net6.0
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OptimizedCharSliceWithPool netcoreapp3.1
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice net472
  • scenario:Benchmarks.Trace.CharSliceBenchmark.OriginalCharSlice netcoreapp3.1
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog net472
  • scenario:Benchmarks.Trace.ILoggerBenchmark.EnrichedLog netcoreapp3.1
  • scenario:Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net472
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive net6.0
  • scenario:Benchmarks.Trace.RedisBenchmark.SendReceive netcoreapp3.1
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishScope net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishSpan net6.0
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes net472
  • scenario:Benchmarks.Trace.SpanBenchmark.StartFinishTwoScopes netcoreapp3.1
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin net472
  • scenario:Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin netcoreapp3.1

/// <returns>true if the value was truncated. false otherwise</returns>
// https://github.com/DataDog/datadog-agent/blob/eac2327c5574da7f225f9ef0f89eaeb05ed10382/pkg/trace/traceutil/truncate.go#L36-L51
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TruncateUTF8(ref string value, int limit)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

naming nit-pick: TruncateUtf8

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

💯, but this name predates these updates by a lot 😄 I'm happy to do the rename, but I'll do that outside of this PR if that's ok 😉

@andrewlock
andrewlock merged commit 3dc6dff into master Jun 30, 2026
146 checks passed
@andrewlock
andrewlock deleted the andrew/truncate-utf-8-improvements branch June 30, 2026 07:33
@github-actions github-actions Bot added this to the vNext-v3 milestone Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:client-side-stats area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) type:performance Performance, speed, latency, resource usage (CPU, memory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants