[
https://issues.apache.org/jira/browse/GEODE-225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15419181#comment-15419181
]
ASF subversion and git services commented on GEODE-225:
-------------------------------------------------------
Commit d62dff949d6883c2196253f7a26eeef921951353 in incubator-geode's branch
refs/heads/develop from [~bschuchardt]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-geode.git;h=d62dff9 ]
GEODE-225 excessive CPU utilization and garbage collection strain for JSON
processing
Use of a singleton ObjectMapper can be enabled using a system property.
-DPdxInstance.use-static-mapper=true
> 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)