Opened 13 years ago

Last modified 12 years ago

#4018 assigned enhancement

don't reparse the same mapfile over and over again for fastcgi

Reported by: tbonfort Owned by: tbonfort
Priority: normal Milestone: 6.2 release
Component: MapServer FastCGI Version: unspecified
Severity: normal Keywords:
Cc:

Description

the given map= mapfile parameter is parsed at each request in the fastcgi mapserv.c

we can squeeze a bit more performance out if we can keep the parsed mapfile in memory, and use a copy of it instead of reparsing it at each request.

The following points should be taken into account when implementing:

  • the behavior should only be active for fastcgi requests
  • a user should be able to disable this for a given mapfile by setting a CONFIG option or an environment variable
  • the original mapfile's modification time should be checked to see if the in-memory copy is stale or not

Change History (2)

comment:1 by tbonfort, 13 years ago

Owner: changed from sdlime to tbonfort
Status: newassigned

initial patch for mapserv.c:

  • mapserv.c

     
    185185{
    186186  int i;
    187187  mapObj *map = NULL;
     188  static char *lastmapname = NULL;
     189  static mapObj *lastmap = NULL;
    188190
    189191  for(i=0;i<mapserv->request->NumParams;i++) /* find the mapfile parameter first */
    190192    if(strcasecmp(mapserv->request->ParamNames[i], "map") == 0) break;
     
    212214      }
    213215
    214216      /* ok to try to load now */
    215       map = msLoadMap(mapserv->request->ParamValues[i], NULL);
     217      if(!lastmapname || strcmp(lastmapname,mapserv->request->ParamValues[i])) {
     218         if(lastmap)
     219            msFreeMap(lastmap);
     220         lastmap = msLoadMap(mapserv->request->ParamValues[i], NULL);
     221         if(lastmapname) free(lastmapname);
     222         lastmapname = strdup(mapserv->request->ParamValues[i]);
     223      }
     224      map = msNewMapObj();
     225      msCopyMap(map,lastmap);
    216226    }
    217227  }

comment:2 by tbonfort, 12 years ago

initial implementation in r13105

Note: See TracTickets for help on using tickets.