-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Enforce 64KB event payload size limit on EventPipe #50600
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
972601a
allow >100KB events to be written
sywhang 77dd874
prevent events > 64KB from being written
sywhang 8e33754
code review feedback
sywhang 60339ee
increment seq num
sywhang 2efcc89
fix build
sywhang baf67b5
fix build on clang
sywhang a38660c
fix mono build
sywhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Diagnostics.Tracing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
using Microsoft.Diagnostics.Tools.RuntimeClient; | ||
using Microsoft.Diagnostics.Tracing; | ||
using Tracing.Tests.Common; | ||
using Microsoft.Diagnostics.Tracing.Parsers.Clr; | ||
|
||
namespace Tracing.Tests.BigEventsValidation | ||
{ | ||
|
||
public sealed class BigEventSource : EventSource | ||
{ | ||
private static string bigString = new String('a', 100 * 1024); | ||
sywhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private static string smallString = new String('a', 10); | ||
|
||
private BigEventSource() | ||
{ | ||
} | ||
|
||
public static BigEventSource Log = new BigEventSource(); | ||
|
||
public void BigEvent() | ||
{ | ||
WriteEvent(1, bigString); | ||
} | ||
|
||
public void SmallEvent() | ||
{ | ||
WriteEvent(2, smallString); | ||
} | ||
} | ||
|
||
|
||
public class BigEventsValidation | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
// This test tries to send a big event (>100KB) and checks that the app does not crash | ||
// See https://github.com/dotnet/runtime/issues/50515 for the regression issue | ||
var providers = new List<Provider>() | ||
{ | ||
new Provider("BigEventSource") | ||
}; | ||
|
||
var configuration = new SessionConfiguration(circularBufferSizeMB: 1024, format: EventPipeSerializationFormat.NetTrace, providers: providers); | ||
return IpcTraceTest.RunAndValidateEventCounts(_expectedEventCounts, _eventGeneratingAction, configuration, _Verify); | ||
} | ||
|
||
private static Dictionary<string, ExpectedEventCount> _expectedEventCounts = new Dictionary<string, ExpectedEventCount>() | ||
{ | ||
{ "BigEventSource", -1 } | ||
}; | ||
|
||
private static Action _eventGeneratingAction = () => | ||
{ | ||
// Write 10 big events | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
BigEventSource.Log.BigEvent(); | ||
} | ||
// Write 10 small events | ||
for (int i = 0; i < 10; i++) | ||
{ | ||
BigEventSource.Log.SmallEvent(); | ||
} | ||
}; | ||
|
||
private static Func<EventPipeEventSource, Func<int>> _Verify = (source) => | ||
{ | ||
bool hasSmallEvent = false; | ||
source.Dynamic.All += (TraceEvent data) => | ||
{ | ||
if (data.EventName == "SmallEvent") | ||
{ | ||
hasSmallEvent = true; | ||
} | ||
}; | ||
return () => hasSmallEvent ? 100 : -1; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> | ||
<OutputType>exe</OutputType> | ||
<CLRTestKind>BuildAndRun</CLRTestKind> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<CLRTestPriority>0</CLRTestPriority> | ||
<JitOptimizationSensitive>true</JitOptimizationSensitive> | ||
<UnloadabilityIncompatible>true</UnloadabilityIncompatible> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
<ProjectReference Include="../common/common.csproj" /> | ||
</ItemGroup> | ||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ETW might limit its payloads to 64KB, but does EventPipe need to?
EventSource
doesn't explicitly prevent you from having payloads this large, e.g., your test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't. But ETW will drop the event if it's greater than 64KB and I'd like to enforce the same behavior here since:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. Let me mull this over, but I think 64KB is fine. Should we remove the
DebugBreak
in theEP_UNLIKELY
macro expansion?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd actually like to keep that. It lets us catch exceptions like this rather than silently failing and us never noticing the failures.