geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruce Schuchardt (JIRA)" <>
Subject [jira] [Issue Comment Deleted] (GEODE-225) excessive CPU utilization and garbage collection strain for JSON processing
Date Thu, 04 Aug 2016 16:23:20 GMT


Bruce Schuchardt updated GEODE-225:
    Comment: was deleted

(was: Performance tests for creating and configuring an Object mapper show that it takes only
a few nanoseconds.  Using the same ObjectMapper in concurrent threads has the potential to
cause threads to stall so I don't think we want to do this.)

> excessive CPU utilization and garbage collection strain for JSON processing
> ---------------------------------------------------------------------------
>                 Key: GEODE-225
>                 URL:
>             Project: Geode
>          Issue Type: Improvement
>          Components: serialization
>    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 =__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,
>           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