Add System.Diagnostics.PerformanceData namespace#31474
Conversation
| { | ||
| if (s_counterSetList.ContainsKey(counterSetGuid)) | ||
| { | ||
| throw new ArgumentException(SR.Format(SR.Perflib_Argument_CounterSetAlreadyRegister, counterSetGuid), "CounterSetGuid"); |
There was a problem hiding this comment.
Please change argument name strings to nameof eg CounterSetGuid to nameof(CounterSetGuid)
There was a problem hiding this comment.
sorry missed that...i'll do another pass
There was a problem hiding this comment.
fixed i did a pass and the other should not be method arguments.
|
@brianrob could someone on your team please take a look (especially at the tests)? |
|
In the NETFX build: @safern any idea what this could be? The types are in System.Core in NETFX. |
The csproj has this references for NETFX <ItemGroup Condition="'$(TargetsNetFx)' == 'true'">
<Reference Include="mscorlib" />
<Reference Include="System" />
</ItemGroup>We need to add |
| <ProjectGuid>{5BDC8641-E3EE-47B5-BE7B-2D2275402412}</ProjectGuid> | ||
| <Configurations>net461-Debug;net461-Release;netfx-Debug;netfx-Release;netstandard-Debug;netstandard-Release</Configurations> | ||
| </PropertyGroup> | ||
| <PropertyGroup> |
There was a problem hiding this comment.
Instead of adding a new PropertyGroup just add this property in the group above.
|
Ugh I missed that thanks @safern. |
|
Adding @adiaaida, who owns performance counters. |
| { | ||
| internal static class UnsafeNativeMethods | ||
| { | ||
| internal const string ADVAPI32 = "advapi32.dll"; |
|
|
||
| [DllImport(ADVAPI32, ExactSpelling = true, EntryPoint = "PerfStopProvider", CharSet = CharSet.Unicode)] | ||
| internal static extern unsafe uint PerfStopProvider( | ||
| [In] IntPtr hProvider |
There was a problem hiding this comment.
can remove [In], [Out] from all the interop definitions https://github.com/Anipik/corefx/blob/master/Documentation/coding-guidelines/interop-pinvokes.md
| internal struct PerfCounterSetInfoStruct | ||
| { | ||
| // PERF_COUNTERSET_INFO structure defined in perflib.h | ||
| [FieldOffset(0)] internal Guid CounterSetGuid; |
There was a problem hiding this comment.
I am not sure if [FieldOffset] attributes are required here.
cc @JeremyKuhne
There was a problem hiding this comment.
You should remove the explicit and offset attributes here. You can then assert in a test that sizeof(PerfCountSetInfoStruct) is 40 if you like.
There was a problem hiding this comment.
Or Debug.Assert somewhere in the code.
There was a problem hiding this comment.
added Asserts before usage
|
|
||
| namespace Microsoft.Win32 | ||
| { | ||
| internal static class UnsafeNativeMethods |
There was a problem hiding this comment.
Follow interop naming conventions https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/interop-guidelines.md
| public class CounterSet : IDisposable | ||
| { | ||
| private static readonly bool s_platformNotSupported = (Environment.OSVersion.Version.Major < 6); | ||
| internal PerfProvider m_provider; |
| /// <param name="providerGuid">ProviderGuid identifies the provider application. A provider identified by ProviderGuid could publish several CounterSets defined by different CounterSetGuids</param> | ||
| /// <param name="counterSetGuid">CounterSetGuid identifies the specific CounterSet. CounterSetGuid should be unique.</param> | ||
| /// <param name="instanceType">One of defined CounterSetInstanceType values</param> | ||
| [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "guid", Justification = "Approved")] |
There was a problem hiding this comment.
@danmosemsft can we remove this and [System.Security.SecuritySafeCritical]?
There was a problem hiding this comment.
[System.Security.SecuritySafeCritical] yes..i'm missed that...i don't know about [SuppressMessage]
There was a problem hiding this comment.
removed [System.Security.SecuritySafeCritical]
There was a problem hiding this comment.
You can remove all SuppressMessage as well I think. They refer to old fxcop rules that we do not run in corefx.
| // Check only the mayor version, only support Windows Vista and later. | ||
| if (s_platformNotSupported) | ||
| { | ||
| throw new System.PlatformNotSupportedException(SR.Perflib_PlatformNotSupported); |
| lock (this) | ||
| { | ||
| PerfProviderCollection.UnregisterCounterSet(m_counterSet); | ||
| if (m_instanceCreated) |
There was a problem hiding this comment.
cheange it to m_instanceCreated && m_provider != null
| namespace System.Diagnostics.PerformanceData | ||
| { | ||
| /// <summary> | ||
| /// CounterSetInstance class maps to "Instace" in native performance counter implementation. |
| /// </summary> | ||
| public sealed class CounterSetInstance : IDisposable | ||
| { | ||
| internal CounterSet m_counterSet; |
| } | ||
| unsafe | ||
| { | ||
| if (m_nativeInst != null) |
| /// Access CounterSetInstanceCounterDataSet property. Developers can then use defined indexer to access | ||
| /// specific CounterData object to query/update raw counter data. | ||
| /// </summary> | ||
| public CounterSetInstanceCounterDataSet Counters |
|
@dotnet-bot test this please |
|
dotnet test Linux x64 Release Build please |
|
dotnet test Linux x64 Release Build please |
|
@danmosemsft @brianrob do you think we need other re-runs? |
|
If we want to prove we have eliminated flakiness we have to run several times |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
@dotnet-bot test this please |
|
@danmosemsft run several times(10) and seems ok...one question, is there a way to check all PR CI run history? |
|
@brianrob or @adiaaida could you please re review? |
|
@adiaaida, PTAL. |
|
Thanks @MarcoRossignoli ! BTW here's another smaller port if you're interested: https://github.com/dotnet/corefx/issues/32103 |
|
Thanks @adiaaida also |
|
thank's to all for help! |
* move System.Diagnostics.PerformanceData from netfx * updates * use type aliases, fix style, cleanup * remove CAS attributes * nit: extralines * Add tests * update tests * update tests * update tests,use type aliases, cleanup * address PR feedback * address some of PR feedback * address some of PR feedback * address some of PR feedback * address PR feedback * added retry/dispose * update tests * try to run new test in isolated process * revert changes to other tests, add retry on new test * fix netfx test fail, add comments Commit migrated from dotnet/corefx@610e9c8
closes https://github.com/dotnet/corefx/issues/30188
/cc @ericstj