Microsoft MVP성태의 닷넷 이야기
기타: 51. DropBox의 CPU 100% 현상 [링크 복사], [링크+제목 복사],
조회: 24009
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
(연관된 글이 1개 있습니다.)

DropBox의 CPU 100% 현상

제 경우에, 드롭 박스 응용 프로그램으로 간단한 메모나 블로그 글을 여러 컴퓨터에 동기화하는 데 사용합니다. 메모 같은 경우에는 크게 상관이 없는데, 블로그 글의 경우 편집/저장을 수시로 하다 보니 드롭 박스(dropbox.exe) 프로세스와 탐색기(explorer.exe) 프로세스가 미친(?) 듯이 CPU를 소비하는 현상이 나타납니다.

물론, dropbox를 종료하고 해당 폴더의 파일을 편집하면 explorer.exe의 CPU 사용률은 다시 잠잠하게 됩니다. 아마도 그 2개의 프로세스가 상호작용하면서 CPU 100% 현상이 더 두드러지는 것 같은데요.

dropbox는 동기화를 하는데 약간 복잡한 (하지만 그들 나름대로 생각하기에는 효율적인) 방법을 사용하고 있는데, 그중 한 요소가 바로 ADS(Alternative Data Stream)을 쓰는 것입니다. 실제로, dropbox 동기화 폴더 하위에 테스트용 폴더 및 파일을 하나 만들고 이를 확인해 볼 수 있습니다. (저는 c:\dropbox\syncfolder로 동기화 폴더를 조정했습니다.)

C:\dropbox\syncfolder\testfolder>dir /a /r
 Volume in drive E has no label.
 Volume Serial Number is 96C5-C7B6

 Directory of C:\dropbox\syncfolder\testfolder
 
2015-01-28  오후 10:20    <DIR>          .
                                      83 .:com.dropbox.attributes:$DATA
2015-01-28  오후 10:20    <DIR>          ..
                                      83 ..:com.dropbox.attributes:$DATA
2015-01-27  오전 08:05             9,585 test.txt
                                      83 test.txt:com.dropbox.attributes:$DATA
               5 File(s)         9,585 bytes
               4 Dir(s)  26,918,531,072 bytes free

파일의 내용은 ADS Viewer 프로그램을 통해 볼 수 있지만,

The V File Viewer
; http://www.fileviewer.com/ADS.html

봐도 별로 도움이 되지는 않습니다. (바이너리 데이터이기 때문에!)

게다가 아마도 dropbox 같은 응용 프로그램은 폴더의 변화를 감지하기 위해 FileSystemWatcher 같은 방법을 썼을 텐데요.

FileSystemWatcher Class
; https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher

FileSystemWatcher in C#
; https://code-maze.com/csharp-filesystemwatcher/

using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            FileSystemWatcher fsw = new FileSystemWatcher(@"C:\dropbox\syncfolder\testfolder");
            fsw.Filter = "*.*";
            fsw.Created += fsw_Created;
            fsw.Changed += fsw_Changed;
            fsw.Deleted += fsw_Deleted;
            fsw.Renamed += fsw_Renamed;
            fsw.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.CreationTime | NotifyFilters.Size | NotifyFilters.FileName;
            fsw.IncludeSubdirectories = true;

            fsw.EnableRaisingEvents = true;

            Console.ReadLine();
        }

        static void fsw_Renamed(object sender, RenamedEventArgs e)
        {
            Console.WriteLine("Renamed: " + e.OldFullPath + " ==> " + e.FullPath);
        }

        static void fsw_Deleted(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine("Deleted: " + e.FullPath);
        }

        static void fsw_Created(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine("Created: " + e.FullPath);
        }

        static void fsw_Changed(object sender, FileSystemEventArgs e)
        {
            Console.WriteLine("Changed: " + e.FullPath);
        }

    }
}


이를 통해 보면, test.txt 파일 저장 하나만으로 다음과 같은 변화가 이벤트로 통보되는 것을 확인할 수 있습니다.

Changed: C:\dropbox\syncfolder\testfolder\test.txt
Changed: C:\dropbox\syncfolder\testfolder\test.txt

(사실, 전 dropbox.exe가 저 간단한 test.txt 파일 변화로 인해 CPU 사용률이 일정 시간동안 널뛰는 것이 이해가/용납이 안 됩니다.)

제가 즐겨쓰는 에디터인 "Visual Studio"와 함께 쓰면 다음과 같이 아주 다양한 숨김 파일들이 생성/삭제가 되어,

Created: C:\dropbox\syncfolder\testfolder\zx01jpdw.p15~
Changed: C:\dropbox\syncfolder\testfolder\zx01jpdw.p15~
Changed: C:\dropbox\syncfolder\testfolder\zx01jpdw.p15~
Changed: C:\dropbox\syncfolder\testfolder\zx01jpdw.p15~
Changed: C:\dropbox\syncfolder\testfolder\zx01jpdw.p15~
Created: C:\dropbox\syncfolder\testfolder\test.txt~RF22fabeac.TMP
Deleted: C:\dropbox\syncfolder\testfolder\test.txt
Changed: C:\dropbox\syncfolder\testfolder\test.txt~RF22fabeac.TMP
Renamed: C:\dropbox\syncfolder\testfolder\zx01jpdw.p15~ ==> C:\dropbox\syncfolder\testfolder\test.txt
Deleted: C:\dropbox\syncfolder\testfolder\test.txt~RF22fabeac.TMP

dropbox.exe의 CPU는 이에 따라 급상승을 하게 됩니다.

제가 dropbox.exe 개발자가 아니기 때문에 이에 대한 해결을 할 수는 없었습니다. 단지, 외적으로 제어를 시도해봤는데요. 평소에는 dropbox.exe를 다음의 도구를 이용해 suspend 시켜 놓았다가,

PsSuspend  
; https://learn.microsoft.com/en-us/sysinternals/downloads/pssuspend

제가 만든 프로그램이 직접 "C:\dropbox\syncfolder" 하위 폴더를 감시하고 있다가 변화가 생기면 그 이벤트를 특정 시간동안 모아놓은 후에 dropbox.exe를 30초간 resume 하는 식으로 처리해 보았습니다.

해보니, 그런 대로 효과가 있었는데요. 문제는 dropbox.exe가 탐색기와 연동하는 부분이 있어서 suspend 상태인 dropbox.exe 때문에 탐색기에서도 멈춤(hang) 현상을 보였습니다. 그래서, 그 다음부터는 suspend/resume 대신 아예 dropbox.exe 프로세스 자체를 종료/시작하는 방식으로 바꿨는데요. 뭐... 그런대로 쓸만해진 것 같습니다. 이 방법의 단점이라면, 시스템 트레이에 이미 종료된 드롭박스 유령 아이콘이 쌓인다는 것인데 마우스로 한번 훑어주면 되기 때문에 CPU High 현상에 비하면 아무것도 아닙니다.

일반 사용자 대상은 좀 그렇고, 혹시 dropbox.exe의 CPU 사용 현상에 불만이 있는 C# 개발자라면 이 프로그램을 가져다 띄워놓으시면 그런대로 스트레스가 줄게 될 거라고 봅니다. ^^ (소스코드와 함께 있습니다.)




참고로, pssuspend로 msmpeng.exe 프로세스까지 중지시키는 것이 가능합니다.

https://twitter.com/0gtweet/status/1638069413717975046?s=20

Looks like the weirdest AV evasion I have ever seen. 
1. Not all MsMpEng.exe versions allow to be suspended.
2. You may need to wait before your malware finally starts.

c:\temp> pssuspend msmpeng.exe
c:\temp> pssuspend -r msmpeng.exe

그런데 msmpeng.exe를 중지하면, 그 프로세스에 정보를 조회하는 다른 모든 프로세스, 일례로 explorer.exe와 같은 프로그램들이 hang 현상에 걸립니다.




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

[연관 글]






[최초 등록일: ]
[최종 수정일: 10/25/2023]

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

비밀번호

댓글 작성자
 



2016-04-11 02시44분
정성태

1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13693정성태7/24/20247233개발 환경 구성: 717. Visual Studio - C# 프로젝트에서 레지스트리에 등록하지 않은 COM 개체 참조 및 사용 방법파일 다운로드1
13692정성태7/24/20248012디버깅 기술: 199. Windbg - 리눅스에서 뜬 닷넷 응용 프로그램 덤프 파일에 포함된 DLL의 Export Directory 탐색
13691정성태7/23/20247369디버깅 기술: 198. Windbg - 스레드의 Win32 Message Queue 정보 조회
13690정성태7/23/20247005오류 유형: 919. Visual C++ 리눅스 프로젝트 - error : ‘u8’ was not declared in this scope
13689정성태7/22/20248509디버깅 기술: 197. Windbg - PE 포맷의 Export Directory 탐색
13688정성태7/21/20247615닷넷: 2281. C# - Lock / Wait 상태에서도 일부 Win32 메시지 처리파일 다운로드1
13687정성태7/19/20248045닷넷: 2280. C# - PostThreadMessage로 보낸 메시지를 Windows Forms에서 수신하는 방법파일 다운로드1
13686정성태7/19/20247842오류 유형: 918. Visual Studio - ATL Simple Object 추가 시 error C2065: 'IDR_...': undeclared identifier
13685정성태7/19/20247990스크립트: 66. Windows 디렉터리 경로를 WSL의 /mnt 포맷으로 구하는 방법 - 두 번째 이야기
13684정성태7/19/20248164닷넷: 2279. C# - 문자열 보간식 사례 (예: 조건 연산자 사용)
13683정성태7/18/20247637오류 유형: 917. ClrMD - Linux 환경의 .NET 5 덤프 분석 시 hang 현상
13682정성태7/18/20247854닷넷: 2278. WPF - 스레드에 종속되는 DependencyObject파일 다운로드1
13681정성태7/17/20247459닷넷: 2277. C# 13 - (2) 메서드 그룹의 자연 타입 개선 (메서드 추론 개선)파일 다운로드1
13680정성태7/16/20247837닷넷: 2276. C# - Method Group, Natural Type, function_type파일 다운로드1
13679정성태7/16/20246934Linux: 76. Linux - C++ (getaddrinfo 등을 담고 있는) libnss 정적 링크
13678정성태7/15/20247051VS.NET IDE: 191. Visual Studio 2022 - .NET 5 프로젝트를 Docker Support로 실행했을 때 오류
13677정성태7/15/20247131오류 유형: 916. MSBuild - CheckEolTargetFramework (warning NETSDK1138)
13676정성태7/14/20247315Linux: 75. gdb에서 glibc의 함수에 Breakpoint 걸기
13675정성태7/13/20249102C/C++: 166. C/C++ - DLL에서 template 함수를 export하는 방법 [1]파일 다운로드1
13674정성태7/13/20247985오류 유형: 915. Unhandled Exception: Microsoft.Diagnostics.NETCore.Client.ServerNotAvailableException: Unable to connect to Process
13673정성태7/11/20248427닷넷: 2275. C# 13 - (1) 신규 이스케이프 시퀀스 '\e'파일 다운로드1
13672정성태7/10/20247142닷넷: 2274. IIS - (프로세스 종료 없는) AppDomain Recycle
13671정성태7/10/20247258오류 유형: 914. Package ca-certificates is not installed.
13669정성태7/9/20247366오류 유형: 913. C# - AOT StaticExecutable 정적 링킹 시 빌드 오류
13668정성태7/8/20247393개발 환경 구성: 716. Hyper-V - Ubuntu 22.04 Generation 2 유형의 VM 설치
13667정성태7/7/20246608닷넷: 2273. C# - 리눅스 환경에서의 Hyper-V Socket 연동 (AF_VSOCK)파일 다운로드1
1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...