Microsoft MVP성태의 닷넷 이야기
Windows: 262. PerformanceCounter의 InstanceName에 pid를 추가한 "Process V2" [링크 복사], [링크+제목 복사],
조회: 1597
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

(시리즈 글이 2개 있습니다.)
.NET Framework: 547. PerformanceCounter의 InstanceName 지정 시 주의 사항
; https://www.sysnet.pe.kr/2/0/10898

Windows: 262. PerformanceCounter의 InstanceName에 pid를 추가한 "Process V2"
; https://www.sysnet.pe.kr/2/0/13585




PerformanceCounter의 InstanceName에 pid를 추가한 "Process V2"

예전 글에서,

PerformanceCounter의 InstanceName 지정 시 주의 사항
; https://www.sysnet.pe.kr/2/0/10898

"Process" 단위로 제공되는 성능 카운터의 경우 InstanceName이 중복되면, 즉 같은 이름의 프로세스가 뜨면 "#[N]"을 붙이는 식으로 명명된다고 했습니다. (심지어, .NET Framework의 경우 다중 런타임이 호스팅되는 환경이라면 각각 #[N] 번호를 갖게 됩니다. 즉, 1개의 EXE 프로세스 내에서도 myapp, myapp#1 2개가 사용될 수 있는 것입니다.)

예를 들어 아래의 그림은 "\Process\% Processor Time"을 선택했을 때의 InstanceName 목록을 보여줍니다.

perf_counter_instance_name_1.png

문제는, 저 InstanceName이 프로세스가 생성/소멸할 때마다 재설정될 수도 있기 때문에 특정 PID를 갖는 대상 프로세스에 대한 InstanceName을 구하기 위해 "\Process\ID Process"로 매번 조회를 해야 합니다.

물론, ProcessNameFormat 레지스트리 설정을 통해 이런 문제를 해결할 수 있지만 기본값이 off이기 때문에 3rd-party 도구를 개발하는 입장에서는 함부로 전역 이름을 바꾸기도 쉽지 않습니다.

마이크로소프트도 이에 대한 인식을 했는지,

About Performance Counters
; https://learn.microsoft.com/en-us/windows/win32/perfctrs/about-performance-counters

For backwards-compatibility reasons, the "Process" counterset returns non-unique instance names based on the EXE filename. This can cause confusing results, especially when a process with a non-unique name starts up or shuts down, as this will typically result in data glitches due to incorrect matching of instance names between samples. Consumers of the "Process" counterset must be able to tolerate these non-unique instance names and the resulting data glitches. In Windows 11 and later, you can use the Process V2 counterset to avoid this problem.


기존의 "Process" 범주에서 제공하던 성능 카운터에 대해 InstanceName 문제가 발생하지 않는 것을 제외한 것들로 새롭게 "Process V2" 범주로 제공하고 있습니다. 예를 들어, 아래는 "Process V2"에서 제공하는 "% ProcessorTime" 항목이 InstanceName 형식으로 process id가 추가된 것을 볼 수 있습니다.

perf_counter_instance_name_2.png

좋은 변화이긴 한데, 너무 늦었다 싶을 정도로 Windows 11/Windows Server 2022에서만 제공된다는 문제가 있습니다. 게다가, 이런 변화를 모든 카운터 변수에 적용하지 못하고 "Process"에 대해서만 제공하므로, 가령 아래와 같이 ".NET CLR Memory"와 같은 범주들은 여전히 기존 방식처럼 제공되고 있습니다.

perf_counter_instance_name_3.png

물론, 하위 호환성으로 인해 저런 것들도 모두 "... V2"로 제공해야겠지만, 글쎄요... 어쨌든 현재는 "Process V2" 범주가 유일한 상황입니다.





[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 3/26/2024]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  [5]  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13521정성태1/11/20242395닷넷: 2199. C# - 한국투자증권 KIS Developers OpenAPI의 WebSocket Ping, Pong 처리
13520정성태1/10/20242179오류 유형: 888. C# - Unable to resolve service for type 'Microsoft.Extensions.ObjectPool.ObjectPool`....'
13519정성태1/10/20242219닷넷: 2198. C# - Reflection을 이용한 ClientWebSocket의 Ping 호출파일 다운로드1
13518정성태1/9/20242482닷넷: 2197. C# - ClientWebSocket의 Ping, Pong 처리
13517정성태1/8/20242295스크립트: 63. Python - 공개 패키지를 이용한 위성 이미지 생성 (pystac_client, odc.stac)
13516정성태1/7/20242400닷넷: 2196. IIS - AppPool의 "Disable Overlapped Recycle" 옵션의 부작용
13515정성태1/6/20242720닷넷: 2195. async 메서드 내에서 C# 7의 discard 구문 활용 사례 [1]
13514정성태1/5/20242379개발 환경 구성: 702. IIS - AppPool의 "Disable Overlapped Recycle" 옵션
13513정성태1/5/20242303닷넷: 2194. C# - WebActivatorEx / System.Web의 PreApplicationStartMethod 특성
13512정성태1/4/20242253개발 환경 구성: 701. IIS - w3wp.exe 프로세스의 ASP.NET 런타임을 항상 Warmup 모드로 유지하는 preload Enabled 설정
13511정성태1/4/20242259닷넷: 2193. C# - ASP.NET Web Application + OpenAPI(Swashbuckle) 스펙 제공
13510정성태1/3/20242174닷넷: 2192. C# - 특정 실행 파일이 있는지 확인하는 방법 (Linux)
13509정성태1/3/20242249오류 유형: 887. .NET Core 2 이하의 프로젝트에서 System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.0.
13508정성태1/3/20242305오류 유형: 886. ORA-28000: the account is locked
13507정성태1/2/20242978닷넷: 2191. C# - IPGlobalProperties를 이용해 netstat처럼 사용 중인 Socket 목록 구하는 방법파일 다운로드1
13506정성태12/29/20232559닷넷: 2190. C# - 닷넷 코어/5+에서 달라지는 System.Text.Encoding 지원
13505정성태12/27/20233128닷넷: 2189. C# - WebSocket 클라이언트를 닷넷으로 구현하는 예제 (System.Net.WebSockets)파일 다운로드1
13504정성태12/27/20232693닷넷: 2188. C# - ASP.NET Core SignalR로 구현하는 채팅 서비스 예제파일 다운로드1
13503정성태12/27/20232579Linux: 67. WSL 환경 + mlocate(locate) 도구의 /mnt 디렉터리 검색 문제
13502정성태12/26/20232635닷넷: 2187. C# - 다른 프로세스의 환경변수 읽는 예제파일 다운로드1
13501정성태12/25/20232389개발 환경 구성: 700. WSL + uwsgi - IPv6로 바인딩하는 방법
13500정성태12/24/20232516디버깅 기술: 194. Windbg - x64 가상 주소를 물리 주소로 변환
13498정성태12/23/20233186닷넷: 2186. 한국투자증권 KIS Developers OpenAPI의 C# 래퍼 버전 - eFriendOpenAPI NuGet 패키지
13497정성태12/22/20232592오류 유형: 885. Visual Studiio - error : Could not connect to the remote system. Please verify your connection settings, and that your machine is on the network and reachable.
13496정성태12/21/20232690Linux: 66. 리눅스 - 실행 중인 프로세스 내부의 환경변수 설정을 구하는 방법 (gdb)
13495정성태12/20/20232622Linux: 65. clang++로 공유 라이브러리의 -static 옵션 빌드가 가능할까요?
1  2  3  4  [5]  6  7  8  9  10  11  12  13  14  15  ...