Changes between Version 11 and Version 12 of MapGuideRfc110


Ignore:
Timestamp:
May 4, 2011, 7:40:17 PM (13 years ago)
Author:
liuar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc110

    v11 v12  
    2424== Overview ==
    2525
    26 This RFC adds an !MgProfilingService which provides some profiling APIs to !MapGuide to help identify resources that need to be optimized and performance bottlenecks.
     26This RFC adds an !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 in !MgProfilingService
    2727
    2828== Motivation ==
    2929
    30 Provide some 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.
     30Profiling 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.
    3131
    3232== Proposed Solution ==
     
    5353}}}
    5454
    55 {{{
    56 MgByteReader* ProfileRenderMapLegend(MgMap* map,
    57                                      INT32 width,
    58                                      INT32 height,
    59                                      MgColor* backgroundColor,
    60                                      CREFSTRING format);
    61 }}}
    62 
    63 {{{
    64 MgByteReader* ProfileResource(MgResourceIdentifier* resource)
    65 }}}
    66 
    67 '''Note: The results of the !ProfileResource() API depends on the type of resource profiled.'''
    68 
    69 The resource types supported by the !ProfileResource() API are:
    70 {{{
    71 MapDefinition
    72 LayerDefinition
    73 FeatureSource
    74 }}}
    75 
    76 All of the above APIs will return an XML document that contains the profiling information gathered.
     55Both of the above APIs will return an XML document that contains the profiling information gathered.
    7756
    7857== Information Gathered ==
    7958
    80 The profiling information gathered will contain a collection of the items below depending on what is applicable.
    81 
    82 !MapDefinition:
     59The profiling information gathered will contain a collection of the items below.
     60
     61!ProfileRenderMap:
    8362{{{
    8463Resource Id
    8564Coordinate System
    86 Extents
    87 Layer Count
    88 Watermark Count
     65Extent
     66Scale
    8967Image Format
    9068Render Map Time
     
    9674}}}
    9775
    98 !LayerDefinition:
     76!ProfileRenderLayer:
    9977{{{
    10078Resource Id
    101 Schema Name
    102 Feature Class Name
    103 Scale Ranges
     79Layer Type
    10480Coordinate System
     81Current Scale Range
    10582Filter
    106 Number of Features
    10783Render Time
    108 Get Idendity Properties Time
    109 Coordinate System Transform Time (Only applies if we are profiling a map rendering process.)
    110 Query Features Time
    111 Stylization Time
    112 }}}
    113 
    114 !FeatureSource:
    115 {{{
    116 Resource Id
    117 Provider Time
    118 IsFromCache
    119 Joins
    120 Calculations
    121 Open Connection Time
    122 Describe Schemas Time
    123 SelectFeatures Time
    124 }}}
    125 
    126 !WatermarkDefinition
     84}}}
     85
     86!ProfileRenderWatermark:
    12787{{{
    12888Resource Id
     
    13191}}}
    13292
    133 Labels:
    134 {{{
    135 Label Count
     93!ProfileRenderLabels:
     94{{{
    13695Render Labels Time
    13796}}}
     
    142101The generated XML report document will be defined by the following schema.
    143102
    144 '''TBD XML document schema'''
    145 
    146 Example of profiling rendering map process: (Work in progress)
    147 {{{
    148 -MapProfileResult
    149   -Map Summary
    150     Resource Id
    151     Resource Id
    152     Coordinate System
    153     Extents
    154     Layer Count
    155     Watermark Count
    156     Image Format
    157     Render Map Time
    158     Render Layers Time
    159     Render Selection Time
    160     Render Watermars Time
    161     Render Labels Time
    162     Create Image Time
    163   -Map Details
    164     -LayerProfileResult
    165       -Layer(s) Summary
    166         Resource Id
    167         Schema Name
    168         Feature Class Name
    169         Scale Ranges
    170         Coordinate System
    171         Filter
    172         Number of Features
    173         Render Time
    174         Get Idendity Properties Time
    175         Coordinate System Transform Time (Only applies if we are profiling a map rendering process.)
    176         Query Features Time
    177         Stylization Time
    178       -Layer(s) Details
    179         +Feature Source(s) Summary
    180         +Feature Source(s) Details
    181     -SelectionProfileResult
    182       Layer(s) Summary
    183       Layer(s) Details
    184     -WatermarkProfileResult
    185       -Watermark(s) Summary
    186         Resource Id
    187         Position Type
    188         Stylization Time
    189       +Watermark(s) Details
    190     -LabelsProfileResult
    191       -Labels Summary
    192         Label Count
    193         Render Labels Time
    194 
     103{{{
     104<?xml version="1.0" encoding="UTF-8"?>
     105<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0.0">
     106  <xs:include schemaLocation="PlatformCommon-1.0.0.xsd"/>
     107  <xs:element name="ProfileResult" type="ProfileResultType"></xs:element>
     108  <xs:complexType name="ProfileResultType">
     109    <xs:choice>
     110      <xs:element name="ProfileRenderMap" type="ProfilerRenderMapType">
     111      </xs:element>
     112      <xs:element name="ProfileRenderDynamicOverlay" type="ProfilerRenderMapType">
     113      </xs:element>
     114      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
     115    </xs:choice>
     116  </xs:complexType>
     117  <xs:complexType name="ProfilerRenderMapType">
     118    <xs:sequence>
     119      <xs:element name="ResourceId" type="xs:string"></xs:element>
     120      <xs:element name="CoordinateSystem" type="xs:string"></xs:element>
     121      <xs:element name="Extent" type="xs:string"></xs:element>
     122      <xs:element name="Scale" type="xs:double"></xs:element>
     123      <xs:element name="ImageFormat" type="xs:string"></xs:element>
     124      <xs:element name="RendererType" type="xs:string"></xs:element>
     125      <xs:element name="RenderTime" type="xs:double"></xs:element>
     126      <xs:element name="ProfileRenderLayers" type="ProfileRenderLayersType"></xs:element>
     127      <xs:element name="ProfileRenderSelection" type="ProfileRenderSelectionType"></xs:element>
     128      <xs:element name="ProfileRenderWatermarks" type="ProfileRenderWatermarksType"></xs:element>
     129      <xs:element name="ProfileRenderLabels" type="ProfileRenderLabelsType"></xs:element>
     130      <xs:element name="CreateImageTime" type="xs:double"></xs:element>
     131      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
     132    </xs:sequence>
     133  </xs:complexType>
     134  <xs:complexType name="ProfileRenderLayersType">
     135    <xs:sequence>
     136      <xs:element name="RenderTime" type="xs:double"></xs:element>
     137      <xs:element name="ProfileRenderLayer" type="ProfileRenderLayerType" minOccurs="0" maxOccurs="unbounded"></xs:element>
     138      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
     139    </xs:sequence>
     140  </xs:complexType>
     141  <xs:complexType name="ProfileRenderSelectionType">
     142    <xs:sequence>
     143      <xs:element name="RenderTime" type="xs:double"></xs:element>
     144      <xs:element name="Filter" type="xs:string"></xs:element>
     145      <xs:element name="ProfileRenderSelectedLayer" type="ProfileRenderLayerType" minOccurs="0" maxOccurs="unbounded"></xs:element>
     146      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
     147    </xs:sequence>
     148  </xs:complexType>
     149  <xs:complexType name="ProfileRenderWatermarksType">
     150    <xs:sequence>
     151      <xs:element name="RenderTime" type="xs:double"></xs:element>
     152      <xs:element name="ProfileRenderWatermark" type="ProfileRenderWatermarkType" minOccurs="0" maxOccurs="unbounded"></xs:element>
     153      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
     154    </xs:sequence>
     155  </xs:complexType>
     156  <xs:complexType name="ProfileRenderLabelsType">
     157    <xs:sequence>
     158      <xs:element name="RenderTime" type="xs:double"></xs:element>
     159      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
     160    </xs:sequence>
     161  </xs:complexType>
     162  <xs:complexType name="ProfileRenderLayerType">
     163    <xs:sequence>
     164      <xs:element name="ResourceId" type="xs:string"></xs:element>
     165      <xs:element name="LayerType" type="xs:string"></xs:element>
     166      <xs:element name="CoordinateSystem" type="xs:string"></xs:element>
     167      <xs:element name="ScaleRange" type="xs:string"></xs:element>
     168      <xs:element name="Filter" type="xs:string"></xs:element>
     169      <xs:element name="RenderTime" type="xs:double"></xs:element>
     170      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
     171    </xs:sequence>
     172  </xs:complexType>
     173  <xs:complexType name="ProfileRenderWatermarkType">
     174    <xs:sequence>
     175      <xs:element name="ResourceId" type="xs:string"></xs:element>
     176      <xs:element name="PositionType" type="xs:string"></xs:element>
     177      <xs:element name="RenderTime" type="xs:double"></xs:element>
     178      <xs:element name="ExtendedData1" type="ExtendedDataType" minOccurs="0"/>
     179    </xs:sequence>
     180  </xs:complexType>
     181</xs:schema>
     182
     183}}}
     184Example of profiling rendering map process:
     185{{{
     186<?xml version="1.0" encoding="utf-8"?>
     187<ProfileResult>
     188  <ProfileRenderMap>
     189    <ResourceId>Library://Shaboygan.MapDefinition</ResourceId>
     190    <CoordinateSystem>LL84</CoordinateSystem>
     191    <Extent>43.73,-87.73,43.75,-87.72</Extent>
     192    <Scale>10000.00</Scale>
     193    <ImageFormat>PNG</ImageFormat>
     194    <RendererType>AGG</RendererType>
     195    <RenderTime>8.30</RenderTime>
     196    <ProfileRenderLayers>
     197      <RenderTime>5.00</RenderTime>
     198      <ProfileRenderLayer>
     199        <ResourceId>Library://Buildings.LayerDefinition</ResourceId>
     200        <LayerType>Vector</LayerType>
     201        <CoordinateSystem>CA-I</CoordinateSystem>
     202        <ScaleRange>ScaleRange1</ScaleRange>
     203        <Filter>FeatId &gt; 5</Filter>
     204        <RenderTime>3.00</RenderTime>
     205      </ProfileRenderLayer>
     206      <ProfileRenderLayer>
     207        <ResourceId>Library://Districts.LayerDefinition</ResourceId>
     208        <LayerType>Raster</LayerType>
     209        <CoordinateSystem>LL84</CoordinateSystem>
     210        <ScaleRange>ScaleRange2</ScaleRange>
     211        <Filter></Filter>
     212        <RenderTime>2.00</RenderTime>
     213      </ProfileRenderLayer>
     214    </ProfileRenderLayers>
     215    <ProfileRenderSelection>
     216      <RenderTime>0.25</RenderTime>
     217      <Filter>FeatId &lt; 100</Filter>
     218      <ProfileRenderSelectedLayer>
     219        <ResourceId>Library://Trees.LayerDefinition</ResourceId>
     220        <LayerType>Vector</LayerType>
     221        <CoordinateSystem>LL84</CoordinateSystem>
     222        <ScaleRange>ScaleRange1</ScaleRange>
     223        <Filter>FeatId &lt; 200</Filter>
     224        <RenderTime>0.10</RenderTime>
     225      </ProfileRenderSelectedLayer>
     226      <ProfileRenderSelectedLayer>
     227        <ResourceId>Library://Parcels.LayerDefinition</ResourceId>
     228        <LayerType>Vector</LayerType>
     229        <CoordinateSystem>LL84</CoordinateSystem>
     230        <ScaleRange>ScaleRange2</ScaleRange>
     231        <Filter></Filter>
     232        <RenderTime>0.15</RenderTime>
     233      </ProfileRenderSelectedLayer>
     234    </ProfileRenderSelection>
     235    <ProfileRenderWatermarks>
     236      <RenderTime>0.75</RenderTime>
     237      <ProfileRenderWatermark>
     238        <ResourceId>Library://Logo.WatermarkDefinition</ResourceId>
     239        <PositionType>Tile</PositionType>
     240        <RenderTime>0.6</RenderTime>
     241      </ProfileRenderWatermark>
     242      <ProfileRenderWatermark>
     243        <ResourceId>Library://Copyright.WatermarkDefinition</ResourceId>
     244        <PositionType>XY</PositionType>
     245        <RenderTime>0.15</RenderTime>
     246      </ProfileRenderWatermark>
     247    </ProfileRenderWatermarks>
     248    <ProfileRenderLabels>
     249      <RenderTime>1.25</RenderTime>
     250    </ProfileRenderLabels>
     251    <CreateImageTime>1</CreateImageTime>
     252  </ProfileRenderMap>
     253</ProfileResult>
    195254}}}
    196255
    197256== Implications ==
    198257
    199 Solution 1.
    200 Copy the implementation of profiling related APIs to !MgServerProfilingService and add profiling code into the copied version, for example, copy the implementation of !RenderMap in !MgServerRenderingService(and all other MG server APIs invoked in !RenderMap) to !MgServerProfilingService. The advantage and disadvantage of this implementation is obvious: less influence on the original implementation but heavy maintenance to do in the future.
    201 
    202 Solution 2.
    203 Inject the profiling code into the original functions being profiled, which means !MgServerServices should be extended to accept a !ProfileResult and the implementation of some APIs will updated to support profiling. For example, to support profiling !RenderMap, all the !MgServerServices in the !RenderMap workflow will be affected - !MgServerRenderingService, !MgServerResourceService, !MgServerFeatureService, !MgServerDescribeSchema, !MgServerSelectFeatures, etc.
    204 
    205 For both solutions, how many code should be copied or updated will be decided by how detailed information would be gathered.
     258To 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, !MgRenderingServerServices needs to be extented by inheriting from !MgProfileManager which provides set/get method for MgProfileResult.
     259
     260[[Image(Class Diagram.PNG)]]
    206261
    207262== Test Plan ==