Microsoft MVP성태의 닷넷 이야기
기타: 51. DropBox의 CPU 100% 현상 [링크 복사], [링크+제목 복사],
조회: 24010
글쓴 사람
정성태 (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)
13641정성태6/11/20248659Linux: 71. Ubuntu 20.04를 22.04로 업데이트
13640정성태6/10/20248833Phone: 21. C# MAUI - Android 환경에서의 파일 다운로드(DownloadManager)
13639정성태6/8/20248443오류 유형: 906. C# MAUI - Android Emulator에서 "Waiting For Debugger"로 무한 대기
13638정성태6/8/20248524오류 유형: 905. C# MAUI - 추가한 layout XML 파일이 Resource.Layout 멤버로 나오지 않는 문제
13637정성태6/6/20248446Phone: 20. C# MAUI - 유튜브 동영상을 MediaElement로 재생하는 방법
13636정성태5/30/20248087닷넷: 2264. C# - 형식 인자로 인터페이스를 갖는 제네릭 타입으로의 형변환파일 다운로드1
13635정성태5/29/20248936Phone: 19. C# MAUI - 안드로이드 "Share" 대상으로 등록하는 방법
13634정성태5/24/20249416Phone: 18. C# MAUI - 안드로이드 플랫폼에서의 Activity 제어 [1]
13633정성태5/22/20248943스크립트: 64. 파이썬 - ASGI를 만족하는 최소한의 구현 코드
13632정성태5/20/20248560Phone: 17. C# MAUI - Android 내에 Web 서비스 호스팅
13631정성태5/19/20249320Phone: 16. C# MAUI - /Download 등의 공용 디렉터리에 접근하는 방법 [1]
13630정성태5/19/20248863닷넷: 2263. C# - Thread가 Task보다 더 빠르다는 어떤 예제(?)
13629정성태5/18/20249163개발 환경 구성: 710. Android - adb.exe를 이용한 파일 전송
13628정성태5/17/20248540개발 환경 구성: 709. Windows - WHPX(Windows Hypervisor Platform)를 이용한 Android Emulator 가속
13627정성태5/17/20248604오류 유형: 904. 파이썬 - UnicodeEncodeError: 'ascii' codec can't encode character '...' in position ...: ordinal not in range(128)
13626정성태5/15/20248872Phone: 15. C# MAUI - MediaElement Source 경로 지정 방법파일 다운로드1
13625정성태5/14/20248929닷넷: 2262. C# - Exception Filter 조건(when)을 갖는 catch 절의 IL 구조
13624정성태5/12/20248720Phone: 14. C# - MAUI에서 MediaElement 사용파일 다운로드1
13623정성태5/11/20248418닷넷: 2261. C# - 구글 OAuth의 JWT (JSON Web Tokens) 해석파일 다운로드1
13622정성태5/10/20249205닷넷: 2260. C# - Google 로그인 연동 (ASP.NET 예제)파일 다운로드1
13621정성태5/10/20248637오류 유형: 903. IISExpress - Failed to register URL "..." for site "..." application "/". Error description: Cannot create a file when that file already exists. (0x800700b7)
13620정성태5/9/20248543VS.NET IDE: 190. Visual Studio가 node.exe를 경유해 Edge.exe를 띄우는 경우
13619정성태5/7/20248860닷넷: 2259. C# - decimal 저장소의 비트 구조파일 다운로드1
13618정성태5/6/20248653닷넷: 2258. C# - double (배정도 실수) 저장소의 비트 구조파일 다운로드1
13617정성태5/5/20249471닷넷: 2257. C# - float (단정도 실수) 저장소의 비트 구조파일 다운로드1
13616정성태5/3/20248617닷넷: 2256. ASP.NET Core 웹 사이트의 HTTP/HTTPS + Dual mode Socket (IPv4/IPv6) 지원 방법파일 다운로드1
1  2  3  4  5  6  7  8  9  10  11  [12]  13  14  15  ...