= !MapGuide RFC 110 - Profiling API enhancement = This page contains a change request (RFC) for the !MapGuide Open Source project. More !MapGuide RFCs can be found on the [wiki:MapGuideRfcs RFCs] page. == Status == ||RFC Template Version||(1.0)|| ||Submission Date|| February 23,2011 || ||Last Modified|| Bruce Dechant, June 5,2011 || ||Author|| Bruce Dechant, Ted Yang, Arthur Liu|| ||RFC Status|| ready for review|| ||Implementation Status||(under development)|| ||Proposed Milestone|| 2.3 || ||Assigned PSC guide(s)||Bruce Dechant|| ||'''Voting History'''||Bruce Dechant, Jackie Ng, Zac Spitzer, Trevor Wekel, Tom Fukushima, Haris Kurtagic|| ||+1|||| ||+0|||| ||-0|||| ||-1|||| ||no vote|||| == Overview == This RFC adds a !MgProfilingService which provides a skeleton for developers to profile existing !MapGuide APIs. !MgProfilingService aims to help developers and end users to identify resources that need to be optimized and performance bottlenecks. Two Profiling APIs will be implemented in this RFC and developers can add their own Profiling API into !MgProfilingService in the future. Also we will implement a UI in Site Admin to help the administrators easily execute a profiling and analyze the result. == Motivation == Profiling APIs that would generate an XML report that could be analyzed to help determine if any resources need to be optimized or if there are performance bottlenecks in the code that need to be looked at. And The UI will offer an visual way to perform the profiling and review the result. == Proposed Solution == The following NEW APIs will be added to the offical API (PHP, Java and .Net): {{{ MgByteReader* ProfileRenderMap(MgMap* map, MgSelection* selection, MgCoordinate* center, double scale, INT32 width, INT32 height, MgColor* backgroundColor, CREFSTRING format, bool bKeepSelection); }}} {{{ MgByteReader* ProfileRenderDynamicOverlay(MgMap* map, MgSelection* selection, MgRenderingOptions* options); }}} Both of the above APIs will return an XML document that contains the profiling information gathered. The UI will be implemented in Site Admin as a php web page. There will be input fields for the required parameters of a profiling. The parameters can also be encoded into the URL so that the profiling UI could be easily integrated with some custom application of !MapGuide. After a profiling has finished with the input parameters, the result XML document will be returned and parsed. Then the webpage will show the total render time for the map, and the render time of each layer in the map. Some additional layer information will be also showed to help the user analyze the results.The result could be exported as .csv file so that the user could do further analysis with other applications like Microsoft Excel. (We are not going to implement the Http API for !MgProfilingService) == Information Gathered == The profiling information gathered for !ProfileRenderMap and !ProfileRenderDynamicOverlay: !ProfileRenderMap: {{{ Resource Id Coordinate System Extent Scale Image Format Render Map Time Render Layers Time Render Selection Time Render Watermars Time Render Labels Time Create Image Time }}} !ProfileRenderLayer: {{{ Resource Id Layer Type Coordinate System Current Scale Range Filter Render Time }}} !ProfileRenderWatermark: {{{ Resource Id Position Type Stylization Time }}} !ProfileRenderLabels: {{{ Render Labels Time }}} == XML Report / Schema == The generated XML report document will be defined by the following schema. {{{ }}} Example of profiling rendering map process: {{{ Library://Shaboygan.MapDefinition LL84 43.73,-87.73,43.75,-87.72 10000.00 PNG AGG 8.30 5.00 Library://Buildings.LayerDefinition Vector CA-I ScaleRange1 FeatId > 5 3.00 Library://Districts.LayerDefinition Raster LL84 ScaleRange2 2.00 0.25 FeatId < 100 Library://Trees.LayerDefinition Vector LL84 ScaleRange1 FeatId < 200 0.10 Library://Parcels.LayerDefinition Vector LL84 ScaleRange2 0.15 0.75 Library://Logo.WatermarkDefinition Tile 0.6 Library://Copyright.WatermarkDefinition XY 0.15 1.25 1 }}} == Implications == To profile an existing !MapGuide API, the profiling code will be injected into the original functions being profiled, which means !MgServerServices should be extended to accept a !MgProfileResult and the implementation of some APIs will be updated to support profiling. For example, to support profiling !RenderMap, !MgRenderingServerService needs to be extented by inheriting from !MgProfileManager which provides set/get method for !MgProfileResult. The injected code will be executed only when the original code being invoked by !ProfilingService, so the the only impact to the original methods will be the extra if/else processing and nothing more. [[Image(Class Diagram.png)]] == Test Plan == !Build/Run on !Windows/Linux == Funding / Resources == Supplied by Autodesk