반응형

http://cafe.naver.com/ongameserver/3952



근래에 회사에서 만들고 있는 게임의 서버 애플리케이션에 LFH을 적용하면서 관련 자료를 좀 모아 보았습니다.


LFH ( Low fragmentation Heap )

1. 단편화 방지를 위해서 만들어진 것이지만 멀티코어 환경에서 특히 좋다.

2. 코어가 하나 있을 때는 오히려 10% 성능 하락도 있다( 신뢰 여부는 측정 불가 ^^; )

3. CRT에서는 크게 성능 향상을 볼 수 없다.
   (nhn Japan 블로그 글에서 CRT도 LFH를 적용했는지 정확하게 모르겠음
    CRT도 LFH 적용을 위해서는 CRT 힙 핸들을 HeapSetInformation에 적용해야 한다 )

4. LFH가 극상의 성능을 내기 위해서 Private Heap과의 조합이 최상이다.

5. Windows Server 2008/Vista 기본적으로 사용되도록 되어 있음
   : 이 때문에 메모리 측정(Private Bytes)를 할 때 정보가 좀 틀릴 수도 있음

6. LFH는 Windows XP, Windows 2000 Professional with SP4, Windows Server 2003 이상 가능



사용 방법

1. 프로세스 힙에 LFH 적용
ULONG ulEnableLFH = 2;
HeapSetInformation (
        GetProcessHeap(), 
        HeapCompatibilityInformation, 
        &ulEnableLFH, 
        sizeof(ulEnableLFH));

2. CRT 힙에 LFH 적용
intptr_t hCrtHeap = _get_heap_handle();
ULONG ulEnableLFH = 2;
if (HeapSetInformation((PVOID)hCrtHeap,
                           HeapCompatibilityInformation,
                           &ulEnableLFH, sizeof(ulEnableLFH)))
        puts("Enabling Low Fragmentation Heap succeeded");
    else
        puts("Enabling Low Fragmentation Heap failed");
    return 0;


반응형

+ Recent posts