Microsoft MVP성태의 닷넷 이야기
기타: 51. DropBox의 CPU 100% 현상 [링크 복사], [링크+제목 복사],
조회: 24007
글쓴 사람
정성태 (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)
13843정성태12/13/20244381오류 유형: 938. Docker container 내에서 빌드 시 error MSB3021: Unable to copy file "..." to "...". Access to the path '...' is denied.
13842정성태12/12/20244534디버깅 기술: 205. Windbg - KPCR, KPRCB
13841정성태12/11/20244866오류 유형: 937. error MSB4044: The "ValidateValidArchitecture" task was not given a value for the required parameter "RemoteTarget"
13840정성태12/11/20244437오류 유형: 936. msbuild - Your project file doesn't list 'win' as a "RuntimeIdentifier"
13839정성태12/11/20244859오류 유형: 936. msbuild - error CS1617: Invalid option '12.0' for /langversion. Use '/langversion:?' to list supported values.
13838정성태12/4/20244595오류 유형: 935. Windbg - Breakpoint 0's offset expression evaluation failed.
13837정성태12/3/20245058디버깅 기술: 204. Windbg - 윈도우 핸들 테이블 (3) - Windows 10 이상인 경우
13836정성태12/3/20244624디버깅 기술: 203. Windbg - x64 가상 주소를 물리 주소로 변환 (페이지 크기가 2MB인 경우)
13835정성태12/2/20245070오류 유형: 934. Azure - rm: cannot remove '...': Directory not empty
13834정성태11/29/20245287Windows: 275. C# - CUI 애플리케이션과 Console 윈도우 (Windows 10 미만의 Classic Console 모드인 경우) [1]파일 다운로드1
13833정성태11/29/20244979개발 환경 구성: 737. Azure Web App에서 Scale-out으로 늘어난 리눅스 인스턴스에 SSH 접속하는 방법
13832정성태11/27/20244909Windows: 274. Windows 7부터 도입한 conhost.exe
13831정성태11/27/20244382Linux: 111. eBPF - BPF_MAP_TYPE_PERF_EVENT_ARRAY, BPF_MAP_TYPE_RINGBUF에 대한 다양한 용어들
13830정성태11/25/20245185개발 환경 구성: 736. 파이썬 웹 앱을 Azure App Service에 배포하기
13829정성태11/25/20245161스크립트: 67. 파이썬 - Windows 버전에서 함께 설치되는 py.exe
13828정성태11/25/20244440개발 환경 구성: 735. Azure - 압축 파일을 이용한 web app 배포 시 디렉터리 구분이 안 되는 문제파일 다운로드1
13827정성태11/25/20245091Windows: 273. Windows 환경의 파일 압축 방법 (tar, Compress-Archive)
13826정성태11/21/20245320닷넷: 2313. C# - (비밀번호 등의) Console로부터 입력받을 때 문자열 출력 숨기기(echo 끄기)파일 다운로드1
13825정성태11/21/20245667Linux: 110. eBPF / bpf2go - BPF_RINGBUF_OUTPUT / BPF_MAP_TYPE_RINGBUF 사용법
13824정성태11/20/20244750Linux: 109. eBPF / bpf2go - BPF_PERF_OUTPUT / BPF_MAP_TYPE_PERF_EVENT_ARRAY 사용법
13823정성태11/20/20245288개발 환경 구성: 734. Ubuntu에 docker, kubernetes (k3s) 설치
13822정성태11/20/20245155개발 환경 구성: 733. Windbg - VirtualBox VM의 커널 디버거 연결 시 COM 포트가 없는 경우
13821정성태11/18/20245079Linux: 108. Linux와 Windows의 프로세스/스레드 ID 관리 방식
13820정성태11/18/20245249VS.NET IDE: 195. Visual C++ - C# 프로젝트처럼 CopyToOutputDirectory 항목을 추가하는 방법
13819정성태11/15/20244490Linux: 107. eBPF - libbpf CO-RE의 CONFIG_DEBUG_INFO_BTF 빌드 여부에 대한 의존성
13818정성태11/15/20245283Windows: 272. Windows 11 24H2 - sudo 추가
1  2  3  [4]  5  6  7  8  9  10  11  12  13  14  15  ...