geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Konstantin Ignatyev (JIRA)" <>
Subject [jira] [Created] (GEODE-225) excessive CPU utilization and garbage collection strain for JSON processing
Date Mon, 17 Aug 2015 22:16:47 GMT
Konstantin Ignatyev created GEODE-225:

             Summary: excessive CPU utilization and garbage collection strain for JSON processing
                 Key: GEODE-225
             Project: Geode
          Issue Type: Improvement
          Components: core
    Affects Versions: 1.0.0-incubating
            Reporter: Konstantin Ignatyev

I have been looking at Geode-s code and come across major performance killer for JSON handling
in Geode, namely implementation of com.gemstone.gemfire.pdx.internal.PdxInstanceImpl#getObject

as you can see in the snipped below the code creates ObjectMapper every time it needs to convert
PDX instance into JSON. According to docs and examples on Jackson’s site instances of  ObjectMapper
should be shared globally. Creating it for every transaction is quite expensive in terms of
CPU and garbage collection.

public Object getObject() {
  if (getPdxType().getNoDomainClass()) { 
    //In case of Developer Rest APIs, All PdxInstances converted from Json will have a className
    //Following code added to convert Json/PdxInstance into the Java object.
      //introspect the JSON, does the @type meta-data exist.
      String className = extractTypeMetaData();
      if(StringUtils.hasText(className)) {
        try {
          ObjectMapper mapper = new ObjectMapper();
          mapper.setDateFormat(new SimpleDateFormat("MM/dd/yyyy"));
          mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
          String JSON = JSONFormatter.toJSON(this);
          Object classInstance = mapper.readValue(JSON, ClassPathLoader.getLatest().forName(className));
          return classInstance;
        }catch(Exception e){
          throw new PdxSerializationException("Could not deserialize as java class type could
not resolved", e);
    return this;

This message was sent by Atlassian JIRA

View raw message