Skip to content
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

[Tests] Update GC SegmentEvents validation #4906

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,9 @@ public async Task TestLogsAllCategoriesDefaultLevel(TestConfiguration config)
/// <summary>
/// Test that log events at the default level are collected for categories without a specified level.
/// </summary>
[SkippableTheory(Skip = "Unreliable test https://github.com/dotnet/diagnostics/issues/3143"), MemberData(nameof(Configurations))]
[SkippableTheory(Skip = "Unreliable test https://github.com/dotnet/diagnostics/issues/2541"), MemberData(nameof(Configurations))]
public async Task TestLogsAllCategoriesDefaultLevelFallback(TestConfiguration config)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2541");
}

using Stream outputStream = await GetLogsAsync(config, settings => {
settings.UseAppFilters = false;
settings.LogLevel = LogLevel.Error;
Expand Down
25 changes: 13 additions & 12 deletions src/tests/eventpipe/GCEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,26 +206,27 @@ await RemoteTestExecutorHelper.RunTestCaseAsync(() => {
Func<EventPipeEventSource, Func<int>> _DoesTraceContainEvents = (source) => {
int GCCreateSegmentEvents = 0;
int GCFreeSegmentEvents = 0;
source.Clr.GCCreateSegment += (eventData) => GCCreateSegmentEvents += 1;
source.Clr.GCFreeSegment += (eventData) => GCFreeSegmentEvents += 1;
if (Environment.Version.Major < 7)
{
source.Clr.GCCreateSegment += (eventData) => GCCreateSegmentEvents += 1;
source.Clr.GCFreeSegment += (eventData) => GCFreeSegmentEvents += 1;
}

int GCAllocationTickEvents = 0;
source.Clr.GCAllocationTick += (eventData) => GCAllocationTickEvents += 1;

int GCCreateConcurrentThreadEvents = 0;
int GCTerminateConcurrentThreadEvents = 0;
source.Clr.GCCreateConcurrentThread += (eventData) => GCCreateConcurrentThreadEvents += 1;
source.Clr.GCTerminateConcurrentThread += (eventData) => GCTerminateConcurrentThreadEvents += 1;

return () => {
Logger.logger.Log("Event counts validation");

Logger.logger.Log("GCCreateSegmentEvents: " + GCCreateSegmentEvents);
Logger.logger.Log("GCFreeSegmentEvents: " + GCFreeSegmentEvents);
bool GCSegmentResult = true;
if (Environment.Version.Major < 7)
{
Logger.logger.Log("GCCreateSegmentEvents: " + GCCreateSegmentEvents);
Logger.logger.Log("GCFreeSegmentEvents: " + GCFreeSegmentEvents);

// Disable checking GCFreeSegmentEvents on .NET 7.0 issue: https://github.com/dotnet/diagnostics/issues/3143
bool GCSegmentResult = GCCreateSegmentEvents > 0 && (GCFreeSegmentEvents > 0 || Environment.Version.Major >= 7);
Logger.logger.Log("GCSegmentResult: " + GCSegmentResult);
GCSegmentResult = GCCreateSegmentEvents > 0 && GCFreeSegmentEvents > 0;
Copy link
Member

Choose a reason for hiding this comment

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

Do we also expect the GCCreateSegmentEvents not to be generated? The test appears to have stopped checking both but the comments only mention GCFreeSegment events stopped. Assuming CreateSegment events are still expected I'd suggest only removing the GCFreeSegmentEvents portion of the check.

I don't think we need to make it conditional on major version either. As long as the test won't start failing when run on older versions it should be fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

In the runtime, there are still technically instances of firing GCCreateSegment_V1 and GCFreeSegment_V1 events. However, from offline discussions summarized in #3143 (comment), this PR is driving towards removing expectations of those events being fired during the new GC.

Since both GCCreateSegment and GCFreeSegment are documented to specifically mean GC segments being created/released, and since the new GC uses regions, I figured that it would be better keep those events to specifically mean GC segments.

Copy link
Member

Choose a reason for hiding this comment

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

if both of those events are affected thats np, the comments elsewhere had given a false impression that the FreeSegment events were the only one impacted.

Logger.logger.Log("GCSegmentResult: " + GCSegmentResult);
}

Logger.logger.Log("GCAllocationTickEvents: " + GCAllocationTickEvents);
bool GCAllocationTickResult = GCAllocationTickEvents > 0;
Expand Down