[ https://issues.apache.org/jira/browse/GEODE-225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15408052#comment-15408052 ]
Bruce Schuchardt commented on GEODE-225: ---------------------------------------- Performance tests show that it takes a microsecond to create and configure an ObjectMapper. Using the same ObjectMapper in concurrent threads could cause a thread to stall so we need to talk about the trade-off. > 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 > > 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)