Microsoft MVP성태의 닷넷 이야기
기타: 51. DropBox의 CPU 100% 현상 [링크 복사], [링크+제목 복사],
조회: 24004
글쓴 사람
정성태 (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)
13917정성태4/30/202548VS.NET IDE: 199. Directory.Build.props에 정의한 속성에 대해 Condition 제약으로 값을 변경하는 방법
13916정성태4/23/2025446디버깅 기술: 221. WinDbg 분석 사례 - ASP.NET HttpCookieCollection을 다중 스레드에서 사용할 경우 무한 루프 현상 - 두 번째 이야기
13915정성태4/13/20251671닷넷: 2331. C# - 실행 시에 메서드 가로채기 (.NET 9)파일 다운로드1
13914정성태4/11/20251978디버깅 기술: 220. windbg 분석 사례 - x86 ASP.NET 웹 응용 프로그램의 CPU 100% 현상 (4)
13913정성태4/10/20251204오류 유형: 950. Process Explorer - 64비트 윈도우에서 32비트 프로세스의 덤프를 뜰 때 "Error writing dump file: Access is denied." 오류
13912정성태4/9/2025864닷넷: 2330. C# - 실행 시에 메서드 가로채기 (.NET 5 ~ .NET 8)파일 다운로드1
13911정성태4/8/20251104오류 유형: 949. WinDbg - .NET Core/5+ 응용 프로그램 디버깅 시 sos 확장을 자동으로 로드하지 못하는 문제
13910정성태4/8/20251257디버깅 기술: 219. WinDbg - 명령어 내에서 환경 변수 사용법
13909정성태4/7/20251740닷넷: 2329. C# - 실행 시에 메서드 가로채기 (.NET Framework 4.8)파일 다운로드1
13908정성태4/2/20252138닷넷: 2328. C# - MailKit: SMTP, POP3, IMAP 지원 라이브러리
13907정성태3/29/20251942VS.NET IDE: 198. (OneDrive, Dropbox 등의 공유 디렉터리에 있는) C# 프로젝트의 출력 경로 변경하기
13906정성태3/27/20252213닷넷: 2327. C# - 초기화되지 않은 메모리에 접근하는 버그?파일 다운로드1
13905정성태3/26/20252247Windows: 281. C++ - Windows / Critical Section의 안정화를 위해 도입된 "Keyed Event"파일 다운로드1
13904정성태3/25/20251905디버깅 기술: 218. Windbg로 살펴보는 Win32 Critical Section파일 다운로드1
13903정성태3/24/20251522VS.NET IDE: 197. (OneDrive, Dropbox 등의 공유 디렉터리에 있는) C++ 프로젝트의 출력 경로 변경하기
13902정성태3/24/20251737개발 환경 구성: 742. Oracle - 테스트용 hr 계정 및 데이터 생성파일 다운로드1
13901정성태3/9/20252127Windows: 280. Hyper-V의 3가지 Thread Scheduler (Classic, Core, Root)
13900정성태3/8/20252346스크립트: 72. 파이썬 - SQLAlchemy + oracledb 연동
13899정성태3/7/20251821스크립트: 71. 파이썬 - asyncio의 ContextVar 전달
13898정성태3/5/20252139오류 유형: 948. Visual Studio - Proxy Authentication Required: dotnetfeed.blob.core.windows.net
13897정성태3/5/20252369닷넷: 2326. C# - PowerShell과 연동하는 방법 (두 번째 이야기)파일 다운로드1
13896정성태3/5/20252192Windows: 279. Hyper-V Manager - VM 목록의 CPU Usage 항목이 항상 0%로 나오는 문제
13895정성태3/4/20252234Linux: 117. eBPF / bpf2go - Map에 추가된 요소의 개수를 확인하는 방법
13894정성태2/28/20252266Linux: 116. eBPF / bpf2go - BTF Style Maps 정의 구문과 데이터 정렬 문제
13893정성태2/27/20252211Linux: 115. eBPF (bpf2go) - ARRAY / HASH map 기본 사용법
[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...