Microsoft MVP성태의 닷넷 이야기
기타: 51. DropBox의 CPU 100% 현상 [링크 복사], [링크+제목 복사],
조회: 17180
글쓴 사람
정성태 (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)
13436정성태11/7/20233073닷넷: 2155. C# - .NET 8 런타임부터 (Reflection 없이) 특성을 이용해 public이 아닌 멤버 호출 가능
13435정성태11/6/20232983닷넷: 2154. C# - 네이티브 자원을 포함한 관리 개체(예: 스레드)의 GC 정리
13434정성태11/1/20232764스크립트: 62. 파이썬 - class의 정적 함수를 동적으로 교체
13433정성태11/1/20232466스크립트: 61. 파이썬 - 함수 오버로딩 미지원
13432정성태10/31/20232546오류 유형: 878. 탐색기의 WSL 디렉터리 접근 시 "Attempt to access invalid address." 오류 발생
13431정성태10/31/20232903스크립트: 60. 파이썬 - 비동기 FastAPI 앱을 gunicorn으로 호스팅
13430정성태10/30/20232743닷넷: 2153. C# - 사용자가 빌드한 ICU dll 파일을 사용하는 방법
13429정성태10/27/20233019닷넷: 2152. Win32 Interop - C/C++ DLL로부터 이중 포인터 버퍼를 C#으로 받는 예제파일 다운로드1
13428정성태10/25/20233097닷넷: 2151. C# 12 - ref readonly 매개변수
13427정성태10/18/20233303닷넷: 2150. C# 12 - 정적 문맥에서 인스턴스 멤버에 대한 nameof 접근 허용(Allow nameof to always access instance members from static context)
13426정성태10/13/20233463스크립트: 59. 파이썬 - 비동기 호출 함수(run_until_complete, run_in_executor, create_task, run_in_threadpool)
13425정성태10/11/20233234닷넷: 2149. C# - PLinq의 Partitioner<T>를 이용한 사용자 정의 분할파일 다운로드1
13423정성태10/6/20233214스크립트: 58. 파이썬 - async/await 기본 사용법
13422정성태10/5/20233355닷넷: 2148. C# - async 유무에 따른 awaitable 메서드의 병렬 및 예외 처리
13421정성태10/4/20233437닷넷: 2147. C# - 비동기 메서드의 async 예약어 유무에 따른 차이
13420정성태9/26/20235687스크립트: 57. 파이썬 - UnboundLocalError: cannot access local variable '...' where it is not associated with a value
13419정성태9/25/20233257스크립트: 56. 파이썬 - RuntimeError: dictionary changed size during iteration
13418정성태9/25/20233953닷넷: 2146. C# - ConcurrentDictionary 자료 구조의 동기화 방식
13417정성태9/19/20233486닷넷: 2145. C# - 제네릭의 형식 매개변수에 속한 (매개변수를 가진) 생성자를 호출하는 방법
13416정성태9/19/20233285오류 유형: 877. redis-py - MISCONF Redis is configured to save RDB snapshots, ...
13415정성태9/18/20233786닷넷: 2144. C# 12 - 컬렉션 식(Collection Expressions)
13414정성태9/16/20233553디버깅 기술: 193. Windbg - ThreadStatic 필드 값을 조사하는 방법
13413정성태9/14/20233744닷넷: 2143. C# - 시스템 Time Zone 변경 시 이벤트 알림을 받는 방법
13412정성태9/14/20237042닷넷: 2142. C# 12 - 인라인 배열(Inline Arrays) [1]
13411정성태9/12/20233537Windows: 252. 권한 상승 전/후 따로 관리되는 공유 네트워크 드라이브 정보
13410정성태9/11/20235072닷넷: 2141. C# 12 - Interceptor (컴파일 시에 메서드 호출 재작성) [1]
1  2  3  4  5  6  7  [8]  9  10  11  12  13  14  15  ...