geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject [1/3] incubator-geode git commit: GEODE-225 excessive CPU utilization and garbage collection strain for JSON processing
Date Fri, 12 Aug 2016 17:37:26 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 1e576f7a6 -> f0eb44eec


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


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/d62dff94
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/d62dff94
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/d62dff94

Branch: refs/heads/develop
Commit: d62dff949d6883c2196253f7a26eeef921951353
Parents: 1e576f7
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Fri Aug 12 10:35:13 2016 -0700
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Fri Aug 12 10:35:13 2016 -0700

----------------------------------------------------------------------
 .../gemfire/pdx/internal/PdxInstanceImpl.java   | 22 ++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d62dff94/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInstanceImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInstanceImpl.java
b/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInstanceImpl.java
index d759c49..53dd958 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInstanceImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxInstanceImpl.java
@@ -16,6 +16,8 @@
  */
 package com.gemstone.gemfire.pdx.internal;
 
+import static org.apache.logging.log4j.message.MapMessage.MapFormat.JSON;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -63,6 +65,18 @@ public class PdxInstanceImpl extends PdxReaderImpl implements PdxInstance,
Senda
 
   private static final long serialVersionUID = -1669268527103938431L;
 
+  private static final boolean USE_STATIC_MAPPER = Boolean.getBoolean("PdxInstance.use-static-mapper");
+
+  static final ObjectMapper mapper = USE_STATIC_MAPPER? createObjectMapper() : null;
+
+  private static ObjectMapper createObjectMapper() {
+    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);
+    return mapper;
+  }
+
   private transient volatile Object cachedObjectForm;
 
   /**
@@ -209,12 +223,9 @@ public class PdxInstanceImpl extends PdxReaderImpl implements PdxInstance,
Senda
         
         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));
+            ObjectMapper objMapper = USE_STATIC_MAPPER? mapper : createObjectMapper();
+            Object classInstance = objMapper.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);
@@ -284,7 +295,6 @@ public class PdxInstanceImpl extends PdxReaderImpl implements PdxInstance,
Senda
         break;
       }
       case OBJECT: {
-        //TODO - we might able to optimize these to not deserialize the object
         Object objectValue = ur.readObject(ft);
         if (objectValue == null) {
           // default value of null does not modify hashCode.


Mime
View raw message