You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Darrel Schneider (JIRA)" <ji...@apache.org> on 2016/02/06 00:32:39 UTC

[jira] [Updated] (GEODE-225) excessive CPU utilization and garbage collection strain for JSON processing

     [ https://issues.apache.org/jira/browse/GEODE-225?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Darrel Schneider updated GEODE-225:
-----------------------------------
    Component/s:     (was: core)
                 serialization

> excessive CPU utilization and garbage collection strain for JSON processing
> ---------------------------------------------------------------------------
>
>                 Key: GEODE-225
>                 URL: https://issues.apache.org/jira/browse/GEODE-225
>             Project: Geode
>          Issue Type: Improvement
>          Components: serialization
>    Affects Versions: 1.0.0-incubating
>            Reporter: Konstantin Ignatyev
>            Assignee: Hitesh Khamesra
>
> 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 =__GEMFIRE_JSON.
>     //Following code added to convert Json/PdxInstance into the Java object.
>     if(this.getClassName().equals("__GEMFIRE_JSON")){
>       
>       //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);
>           mapper.configure(com.fasterxml.jackson.core.JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
>           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
(v6.3.4#6332)