Skip to content

Commit 647a8d0

Browse files
committed
Reverted moved MemoryDiagnoserTests to ManualRunning.
Disabled EventSource for integration tests.
1 parent 0da5eba commit 647a8d0

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<Content Include="xunit.runner.json">
1919
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2020
</Content>
21+
<!-- Disable EventSource to stabilize MemoryDiagnoserTests. https://github.com/dotnet/BenchmarkDotNet/pull/2562#issuecomment-2081317379 -->
22+
<RuntimeHostConfigurationOption Include="System.Diagnostics.Tracing.EventSource.IsSupported" Value="false" />
2123
</ItemGroup>
2224
<ItemGroup>
2325
<ProjectReference Include="..\BenchmarkDotNet.IntegrationTests.ConfigPerAssembly\BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj" />

tests/BenchmarkDotNet.IntegrationTests.ManualRunning/MemoryDiagnoserTests.cs renamed to tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs

+16-6
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@
2424
using Xunit.Abstractions;
2525
using BenchmarkDotNet.Toolchains.Mono;
2626

27-
namespace BenchmarkDotNet.IntegrationTests.ManualRunning
27+
namespace BenchmarkDotNet.IntegrationTests
2828
{
29-
// #1925
30-
// These tests were moved to ManualRunning to stabilize the CI.
31-
// Even after disabling tiered jit and blocking the finalizer thread, the tests are still flaky on CI.
3229
public class MemoryDiagnoserTests
3330
{
3431
private readonly ITestOutputHelper output;
@@ -54,6 +51,7 @@ public class AccurateAllocations
5451
}
5552

5653
[Theory, MemberData(nameof(GetToolchains))]
54+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
5755
public void MemoryDiagnoserIsAccurate(IToolchain toolchain)
5856
{
5957
long objectAllocationOverhead = IntPtr.Size * 2; // pointer to method table + object header word
@@ -111,6 +109,7 @@ private void AllocateUntilGcWakesUp()
111109
}
112110

113111
[Theory, MemberData(nameof(GetToolchains))]
112+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
114113
public void MemoryDiagnoserDoesNotIncludeAllocationsFromSetupAndCleanup(IToolchain toolchain)
115114
{
116115
AssertAllocations(toolchain, typeof(AllocatingGlobalSetupAndCleanup), new Dictionary<string, long>
@@ -136,6 +135,7 @@ public ulong TimeConsuming()
136135
}
137136

138137
[Theory, MemberData(nameof(GetToolchains))]
138+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
139139
public void EngineShouldNotInterfereAllocationResults(IToolchain toolchain)
140140
{
141141
AssertAllocations(toolchain, typeof(NoAllocationsAtAll), new Dictionary<string, long>
@@ -146,6 +146,7 @@ public void EngineShouldNotInterfereAllocationResults(IToolchain toolchain)
146146

147147
// #1542
148148
[Theory, MemberData(nameof(GetToolchains))]
149+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
149150
public void TieredJitShouldNotInterfereAllocationResults(IToolchain toolchain)
150151
{
151152
AssertAllocations(toolchain, typeof(NoAllocationsAtAll), new Dictionary<string, long>
@@ -161,6 +162,7 @@ public class NoBoxing
161162
}
162163

163164
[Theory, MemberData(nameof(GetToolchains))]
165+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
164166
public void EngineShouldNotIntroduceBoxing(IToolchain toolchain)
165167
{
166168
AssertAllocations(toolchain, typeof(NoBoxing), new Dictionary<string, long>
@@ -181,6 +183,7 @@ public class NonAllocatingAsynchronousBenchmarks
181183
}
182184

183185
[Theory, MemberData(nameof(GetToolchains))]
186+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
184187
public void AwaitingTasksShouldNotInterfereAllocationResults(IToolchain toolchain)
185188
{
186189
AssertAllocations(toolchain, typeof(NonAllocatingAsynchronousBenchmarks), new Dictionary<string, long>
@@ -205,6 +208,7 @@ private void DoNotInline(object left, object right) { }
205208
}
206209

207210
[Theory, MemberData(nameof(GetToolchains))]
211+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
208212
public void AllocatedMemoryShouldBeScaledForOperationsPerInvoke(IToolchain toolchain)
209213
{
210214
long objectAllocationOverhead = IntPtr.Size * 2; // pointer to method table + object header word
@@ -230,6 +234,7 @@ public byte[] SixtyFourBytesArray()
230234
}
231235

232236
[TheoryEnvSpecific("Full Framework cannot measure precisely enough for low invocation counts.", EnvRequirement.DotNetCoreOnly), MemberData(nameof(GetToolchains))]
237+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
233238
public void AllocationQuantumIsNotAnIssueForNetCore21Plus(IToolchain toolchain)
234239
{
235240
long objectAllocationOverhead = IntPtr.Size * 2; // pointer to method table + object header word
@@ -295,6 +300,7 @@ public void Allocate()
295300

296301
[TheoryEnvSpecific("Full Framework cannot measure precisely enough", EnvRequirement.DotNetCoreOnly)]
297302
[MemberData(nameof(GetToolchains))]
303+
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
298304
public void MemoryDiagnoserIsAccurateForMultiThreadedBenchmarks(IToolchain toolchain)
299305
{
300306
long objectAllocationOverhead = IntPtr.Size * 2; // pointer to method table + object header word
@@ -319,8 +325,12 @@ private void AssertAllocations(IToolchain toolchain, Type benchmarkType, Diction
319325
}
320326
catch (MisconfiguredEnvironmentException e)
321327
{
322-
output.WriteLine(e.SkipMessage);
323-
return;
328+
if (ContinuousIntegration.IsLocalRun())
329+
{
330+
output.WriteLine(e.SkipMessage);
331+
return;
332+
}
333+
throw;
324334
}
325335

326336
foreach (var benchmarkAllocationsValidator in benchmarksAllocationsValidators)

0 commit comments

Comments
 (0)