Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add System.Diagnostics.PerformanceData namespace#31474

Merged
danmoseley merged 19 commits into
dotnet:masterfrom
MarcoRossignoli:performancedata
Sep 4, 2018
Merged

Add System.Diagnostics.PerformanceData namespace#31474
danmoseley merged 19 commits into
dotnet:masterfrom
MarcoRossignoli:performancedata

Conversation

@MarcoRossignoli
Copy link
Copy Markdown
Member

{
if (s_counterSetList.ContainsKey(counterSetGuid))
{
throw new ArgumentException(SR.Format(SR.Perflib_Argument_CounterSetAlreadyRegister, counterSetGuid), "CounterSetGuid");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please change argument name strings to nameof eg CounterSetGuid to nameof(CounterSetGuid)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sorry missed that...i'll do another pass

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed i did a pass and the other should not be method arguments.

@danmoseley
Copy link
Copy Markdown
Member

@brianrob could someone on your team please take a look (especially at the tests)?

@danmoseley
Copy link
Copy Markdown
Member

In the NETFX build:

D:\j\workspace\windows-TGrou---2a8f9c29\Tools\partialfacades.task.targets(64,5): warning : Did not find type 'T:System.Diagnostics.PerformanceData.CounterData' in any of the seed assemblies. [D:\j\workspace\windows-TGrou---2a8f9c29\src\System.Diagnostics.PerformanceCounter\src\System.Diagnostics.PerformanceCounter.csproj]
D:\j\workspace\windows-TGrou---2a8f9c29\Tools\partialfacades.task.targets(64,5): warning : Did not find type 'T:System.Diagnostics.PerformanceData.CounterSet' in any of the seed assemblies. [D:\j\workspace\windows-TGrou---2a8f9c29\src\System.Diagnostics.PerformanceCounter\src\System.Diagnostics.PerformanceCounter.csproj]
D:\j\workspace\windows-TGrou---2a8f9c29\Tools\partialfacades.task.targets(64,5): warning : Did not find type 'T:System.Diagnostics.PerformanceData.CounterSetInstance' in any of the seed assemblies. [D:\j\workspace\windows-TGrou---2a8f9c29\src\System.Diagnostics.PerformanceCounter\src\System.Diagnostics.PerformanceCounter.csproj]
D:\j\workspace\windows-TGrou---2a8f9c29\Tools\partialfacades.task.targets(64,5): warning : Did not find type 'T:System.Diagnostics.PerformanceData.CounterSetInstanceCounterDataSet' in any of the seed assemblies. [D:\j\workspace\windows-TGrou---2a8f9c29\src\System.Diagnostics.PerformanceCounter\src\System.Diagnostics.PerformanceCounter.csproj]
D:\j\workspace\windows-TGrou---2a8f9c29\Tools\partialfacades.task.targets(64,5): warning : Did not find type 'T:System.Diagnostics.PerformanceData.CounterSetInstanceType' in any of the seed assemblies. [D:\j\workspace\windows-TGrou---2a8f9c29\src\System.Diagnostics.PerformanceCounter\src\System.Diagnostics.PerformanceCounter.csproj]
D:\j\workspace\windows-TGrou---2a8f9c29\Tools\partialfacades.task.targets(64,5): warning : Did not find type 'T:System.Diagnostics.PerformanceData.CounterType' in any of the seed assemblies. [D:\j\workspace\windows-TGrou---2a8f9c29\src\System.Diagnostics.PerformanceCounter\src\System.Diagnostics.PerformanceCounter.csproj]
D:\j\workspace\windows-TGrou---2a8f9c29\Tools\partialfacades.task.targets(64,5): warning : Errors were encountered while generating the facade. [D:\j\workspace\windows-TGrou---2a8f9c29\src\System.Diagnostics.PerformanceCounter\src\System.Diagnostics.PerformanceCounter.csproj]
D:\j\workspace\windows-TGrou---2a8f9c29\Tools\partialfacades.task.targets(64,5): error : Errors were encountered when generating facade(s). [D:\j\workspace\windows-TGrou---2a8f9c29\src\System.Diagnostics.PerformanceCounter\src\System.Diagnostics.PerformanceCounter.csproj]

@safern any idea what this could be? The types are in System.Core in NETFX.

@safern
Copy link
Copy Markdown
Member

safern commented Jul 30, 2018

@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 System.Core reference to both, ref and src csproj.

<ProjectGuid>{5BDC8641-E3EE-47B5-BE7B-2D2275402412}</ProjectGuid>
<Configurations>net461-Debug;net461-Release;netfx-Debug;netfx-Release;netstandard-Debug;netstandard-Release</Configurations>
</PropertyGroup>
<PropertyGroup>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of adding a new PropertyGroup just add this property in the group above.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

@danmoseley
Copy link
Copy Markdown
Member

Ugh I missed that thanks @safern.

@danmoseley danmoseley requested a review from brianrob July 30, 2018 18:48
@brianrob
Copy link
Copy Markdown
Member

Adding @adiaaida, who owns performance counters.

{
internal static class UnsafeNativeMethods
{
internal const string ADVAPI32 = "advapi32.dll";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Delete this and use Libraries.advapi

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed


[DllImport(ADVAPI32, ExactSpelling = true, EntryPoint = "PerfStopProvider", CharSet = CharSet.Unicode)]
internal static extern unsafe uint PerfStopProvider(
[In] IntPtr hProvider
Copy link
Copy Markdown

@Anipik Anipik Jul 30, 2018

Choose a reason for hiding this comment

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

internal struct PerfCounterSetInfoStruct
{
// PERF_COUNTERSET_INFO structure defined in perflib.h
[FieldOffset(0)] internal Guid CounterSetGuid;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I am not sure if [FieldOffset] attributes are required here.

cc @JeremyKuhne

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should remove the explicit and offset attributes here. You can then assert in a test that sizeof(PerfCountSetInfoStruct) is 40 if you like.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or Debug.Assert somewhere in the code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

added Asserts before usage


namespace Microsoft.Win32
{
internal static class UnsafeNativeMethods
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

public class CounterSet : IDisposable
{
private static readonly bool s_platformNotSupported = (Environment.OSVersion.Version.Major < 6);
internal PerfProvider m_provider;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove m_ from all the names

/// <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")]
Copy link
Copy Markdown

@Anipik Anipik Jul 30, 2018

Choose a reason for hiding this comment

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

@danmosemsft can we remove this and [System.Security.SecuritySafeCritical]?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[System.Security.SecuritySafeCritical] yes..i'm missed that...i don't know about [SuppressMessage]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed [System.Security.SecuritySafeCritical]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove System.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

i removed check

lock (this)
{
PerfProviderCollection.UnregisterCounterSet(m_counterSet);
if (m_instanceCreated)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

cheange it to m_instanceCreated && m_provider != null

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed

namespace System.Diagnostics.PerformanceData
{
/// <summary>
/// CounterSetInstance class maps to "Instace" in native performance counter implementation.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

typo instance

Copy link
Copy Markdown
Member Author

@MarcoRossignoli MarcoRossignoli Jul 31, 2018

Choose a reason for hiding this comment

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

fixed

/// </summary>
public sealed class CounterSetInstance : IDisposable
{
internal CounterSet m_counterSet;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similar thing about removing the m_

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

}
unsafe
{
if (m_nativeInst != null)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

combine all the ifs with and operation

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

/// Access CounterSetInstanceCounterDataSet property. Developers can then use defined indexer to access
/// specific CounterData object to query/update raw counter data.
/// </summary>
public CounterSetInstanceCounterDataSet Counters
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use autoimplemented properties

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

@dotnet-bot test this please

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

dotnet test Linux x64 Release Build please
dotnet test NETFX x86 Release Build please
dotnet test UWP CoreCLR x64 Debug Build please

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

dotnet test Linux x64 Release Build please

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

@danmosemsft @brianrob do you think we need other re-runs?

@danmoseley
Copy link
Copy Markdown
Member

If we want to prove we have eliminated flakiness we have to run several times
@dotnet-bot test this please

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

MarcoRossignoli commented Aug 31, 2018

@dotnet-bot test this please
success.
unrelated fail
Packaging All Configurations x64 Debug Build
00:09:30 System\Runtime\InteropServices\Marshal\ChangeWrapperHandleStrengthTests.cs(61,37): error CS1061: 'TypeBuilder' does not contain a definition for 'CreateType' and no extension method 'CreateType' accepting a first argument of type 'TypeBuilder' could be found (are you missing a using directive or an assembly reference?) [D:\j\workspace\windows-TGrou---0d2c9ac4\src\System.Runtime.InteropServices\tests\System.Runtime.InteropServices.Tests.csproj]

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

MarcoRossignoli commented Aug 31, 2018

@dotnet-bot test this please
success.
unrelated fails
OSX x64 Debug Build
Packaging All Configurations x64 Debug Build

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

MarcoRossignoli commented Aug 31, 2018

@dotnet-bot test this please
success
unrelated fail Packaging All Configurations x64 Debug Build

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

MarcoRossignoli commented Aug 31, 2018

@dotnet-bot test this please
success
unrelated fail
Linux x64 Release Build
Packaging All Configurations x64 Debug Build

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

MarcoRossignoli commented Aug 31, 2018

@dotnet-bot test this please
success
unrelated fail
Packaging All Configurations x64 Debug Build

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

MarcoRossignoli commented Aug 31, 2018

@dotnet-bot test this please
success
unrelated fail
Packaging All Configurations x64 Debug Build

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

MarcoRossignoli commented Sep 1, 2018

@dotnet-bot test this please
success
unrelated fail
Packaging All Configurations x64 Debug Build
UWP CoreCLR x64 Debug Build

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

MarcoRossignoli commented Sep 2, 2018

@dotnet-bot test this please
success
unrelated fail
OSX x64 Debug Build

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

@dotnet-bot test this please

@MarcoRossignoli
Copy link
Copy Markdown
Member Author

@danmosemsft run several times(10) and seems ok...one question, is there a way to check all PR CI run history?

@danmoseley
Copy link
Copy Markdown
Member

@brianrob or @adiaaida could you please re review?

@brianrob
Copy link
Copy Markdown
Member

brianrob commented Sep 4, 2018

@adiaaida, PTAL.

@danmoseley danmoseley merged commit 610e9c8 into dotnet:master Sep 4, 2018
@danmoseley
Copy link
Copy Markdown
Member

Thanks @MarcoRossignoli !

BTW here's another smaller port if you're interested: https://github.com/dotnet/corefx/issues/32103

@danmoseley
Copy link
Copy Markdown
Member

Thanks @adiaaida also

@MarcoRossignoli MarcoRossignoli deleted the performancedata branch September 5, 2018 07:20
@MarcoRossignoli
Copy link
Copy Markdown
Member Author

thank's to all for help!

@karelz karelz added this to the 3.0 milestone Sep 6, 2018
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PerformanceData types are missing from System.Diagnostics.PerformanceCounters