Habitat Memory Issues Solution through WCF Remoting Introduction
Habitat Memory Issues Solution through WCF Remoting
Introduction • Habitat uses PC Raster for grid calculations • Models (grids) are typically large – Extreme (typical? ) case: 9. 3 Gb
Problem • PC Raster + Delta Shell = – High memory usage – Memory fragmentation => Out. Of. Memory. Exception • Fragmentation => Unable to allocate large blocks
Remoting • Separate process: Old: – Delta Shell – PC Raster Delta Shell. exe PC Raster Model API Process Boundary or Network boundary Delta Shell. exe Remote Server. exe PC Raster Formula Based WCF Model API Model Serialization Proxy WCF TCP / Named Pipe / HTTP PC Raster Model API PC Raster
Remoting in practice • Define (serializable) API • Decorate API for Remoting • Get Proxy • Done!
Remoting in practice • Define API / Decorate API: • Serializable! • Proto. Behavior (Proto. Buf): compact serialization framework
Remoting in practice • Get Proxy • Ideally: use original concrete class • Done!! – Cleanup: Remote. Instance. Container. Remove. Instance()
Remote Remoting: TCP Chunking • Use case: – supercomputer, – distributed computers TCP – – Advantages: Can use remote resources Disadvantages: • Slow • Inefficient memory usage due to WCF serialization overhead! • Max transferable (with chunking): +/- 100 mb (without chunking: 30 mb)
TCP Chunking • Chunking: – Split a large message (eg, large array) into smaller pieces – More memory efficient (fragmentation) • Decoration
Local Remoting: Shared Memory • Remoting Serialization/Deserialization: – Re-introduces the memory issues we want to solve – Adds performance issues – Chunking only partly solves this => No solution for Habitat • Solution: – – Don’t transfer large arrays with remoting Use inter-process memory sharing Use Remoting to transfer the ‘memory pointers’ Pull-based: receiver retrieves memory from sending process
Shared Memory (2) • PC Memory: A B 1 2 3 4 Delta Shell C D E F G H I J Remote Server 5 6 7 8 9 10
Shared Memory (2): Array • Use Win 32 API • Extend Serializable. Array:
Shared Memory (3)
Shared Memory (4) • Disadvantages: – Takes 1 second to initialize remote class (on first call) • Advantages – Memory: hardly any overhead – Speed: 1 Gb takes 1 second – PCRaster specific: no need to copy to managed memory on server • Test with 9. 3 Gb case (125 models): – No Remoting: Out. Of. Memory. Exception – Shared Memory Remoting: Success* * Although some models fail for other reasons
Conclusion • Shared Memory works well • Improve performance Remoting – Eg, the supercomputer case • Improve error handling & recovery – Restart instances? State is lost. .
Questions?
- Slides: 16