Closed performanceautofiler[bot] closed 3 months ago
@EgorBo is this by design, so it could be closed?
@EgorBot -amd64 -intel -perf -commit 79dd9bae9bb881eb716b608577c4cedc6c9cba72 vs fab69efde7d2458dfb23e01b686842cf6d7f576d --disasm
using BenchmarkDotNet.Attributes;
using System.Text;
public class MyProgram
{
const int LOHAllocatedStringSize = 100_000;
private string _stringLOH;
private string _string100;
private StringBuilder _builderSingleSegment100;
private StringBuilder _builderSingleSegmentLOH;
private StringBuilder _builderMultipleSegments100;
private StringBuilder _builderMultipleSegmentsLOH;
[GlobalSetup(Target = nameof(ToString_MultipleSegments))]
public void Setup_ToString_MultipleSegments()
{
_builderMultipleSegments100 = Append_Char(100); // 16 + 32 + 48 + 96 char segments
_builderMultipleSegmentsLOH = Append_Char(LOHAllocatedStringSize);
}
public StringBuilder Append_Char(int length)
{
StringBuilder builder = new StringBuilder();
for (int i = 0; i < length; i++)
builder.Append('a');
return builder;
}
[Benchmark]
[Arguments(LOHAllocatedStringSize)]
public string ToString_MultipleSegments(int length) => (length == 100 ? _builderMultipleSegments100 : _builderMultipleSegmentsLOH).ToString();
}
@EgorBo so the regression still exists?
@EgorBo so the regression still exists?
It does, but there is not much we can do here.
Previously we used to call native memmove
directly (in coop mode), now we call managed SpanHelpers.Memmove
instead that forwards back to native memmove
(with gc transition) for large sizes, so we effectively pay for that wrapper. It only happens for large sizes.
Since there are more improvements (11) than regressions (4) and the fact that that PR: 1) Fixed a bug on NAOT: https://github.com/dotnet/runtime/issues/95517 2) Made Memmove more suspension friendly: https://github.com/dotnet/runtime/issues/98620
we can close it.
Run Information
Regressions in System.Text.Tests.Perf_StringBuilder
Test Report
Repro
General Docs link: https://github.com/dotnet/performance/blob/main/docs/benchmarking-workflow-dotnet-runtime.md