Netcf Gc

15
MPT Talk : NETCF GC Abhinaba Basu http://blogs.msdn.com/abhinaba

Transcript of Netcf Gc

Page 1: Netcf Gc

MPT Talk : NETCF GCAbhinaba Basu

http://blogs.msdn.com/abhinaba

Page 2: Netcf Gc

64K object pools Large (>16K) and

huge objects (>64K) Per app domain

finalizer thread

Memory architecture

Pool 0 Pool 1

Pool 2

App State

Fast free

Page 3: Netcf Gc

Targeted towards diverse devices Non generational mark-sweep-compaction Highest cost is compaction

◦ Fired when fragmentation > 750K GC can trigger code pitching GC triggers

◦ Allocation fails◦ Quanta of allocation◦ User code forces GC◦ When app goes to background

NETCF GC - Current State

Page 4: Netcf Gc

Actively engaging with ◦ Desktop SL team◦ Desktop CLR GC folks◦ XNA team

Measure, measure and then measure some more

Development of tools for memory simulations

Current investigations – Data Collection

Page 5: Netcf Gc

60% to 85% of memory in native heap with 80 MB working set◦ Native heap allocations don’t impact GC perf◦ Images, in native heap, dominate working set

Desktop GC inadequate in this scenario Unsuccessfully attempted Add/Remove

Memory pressure SL drives GC Suggested we tweak our GC to be total

memory aware and expose hosting API

SL Desktop

Page 6: Netcf Gc

Memory simulation

Page 7: Netcf Gc

Tools

Page 8: Netcf Gc

GC Perf Data for Managed Allocs

1 2 3.2 4.3 5.5 6.7 7.8 9 100

50

100

150

200

250

Garbage per sec:100K

Managed Heap Working Set

GC latency (milli sec)

Samsung Mirage

OMAP - 10 mb managed data1. Without 60ms2. With compaction 186ms3. 26MB Compaction 324ms

Page 9: Netcf Gc

60-80% of working set is native Linear degradation with increase in managed

working set Expected max is 50MB Managed WS < 10MB generally works fine Managed WS >100MB experiences “hangs” UI over web-services, small data works fine UI over large in-memory data has large startup

time Multi-media, games can have small freezes

(200ms) on full GC SL apps with lot of native memory may run into

OOM even when memory can be reclaimed

Apps and Issues

Page 10: Netcf Gc

Refactoring to allow GC in-built profiles Auto-tuning to reduce the number of GC Configurability Hosting changes

Current Investigation - Prototypes

Page 11: Netcf Gc

Auto tune internal thresholds◦ Collection threshold/budget◦ Fragmentation threshold for compaction

Native allocation aware System memory aware Low memory state

Auto Tuning

Page 12: Netcf Gc

Support GC policies◦ Currently limited hand tuning for entire CLR◦ Per process GC config (*.exe.config)

Downloaded application cannot override System applications can change Quanta, disable

pitching Add GC Hosting API’s

◦ ICLRHostManager::Collect◦ ICLRManager::SetGCStartupLimits◦ IHostMemoryManager::GetMemoryLoad◦ IHostGCManager::GCNotification

Configurable

Page 13: Netcf Gc

CE 6.0 memory model changes Hand optimization Generational GC

◦ Current data on desktop SL suggests against it

Other changes

Page 14: Netcf Gc

Xbox and other large systems bring in special challenges

Per CPU heap/allocation context Parallel GC on multi-proc systems Pre-fetch Current focus is Mobile scenarios

Platform specific