[jbosscache-commits] JBoss Cache SVN: r5306 - in core/trunk: src/main/docbook/userguide/en/modules and 5 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Tue Feb 5 20:19:52 EST 2008
Author: manik.surtani at jboss.com
Date: 2008-02-05 20:19:52 -0500 (Tue, 05 Feb 2008)
New Revision: 5306
Modified:
core/trunk/
core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller210.java
core/trunk/src/main/java/org/jboss/cache/marshall/MarshalledValueHelper.java
core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java
Log:
Performance related changes, including:
1) Backing out JBCACHE-811
2) Implicit marshalled values (UseLazyDeserialization) defaults to false now, since it adds a slight - about 1% - overhead.
Property changes on: core/trunk
___________________________________________________________________
Name: svn:ignore
- output
build.log
junit*
0000*
je.lck
*.iml
*.ipr
*.iws
bin
jbossdb
dist
derby.log
target
+ output
build.log
junit*
0000*
je.lck
*.iml
*.ipr
*.iws
bin
jbossdb
dist
derby.log
target
build
Modified: core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2008-02-06 01:19:52 UTC (rev 5306)
@@ -700,43 +700,14 @@
<entry>
<para>An optional parameter that can be used to enable or disable the use of lazy deserialization
- for cached objects. Defaults to<literal>true</literal>. If lazy deserialization is disabled,
- support for implicitly using context class loaders registered with the calling thread goes away.
+ for cached objects. Defaults to<literal>false</literal>, since it adds a small processing
+ overhead.
+ If lazy deserialization is disabled, support for implicitly using context class loaders
+ registered
+ with the calling thread goes away.
</para>
</entry>
</row>
-
- <row>
- <entry>
- <para>UseReferenceCounting</para>
- </entry>
-
- <entry>
- <para>
- An optional parameter that is used to control how identical objects are marshalled. If reference
- counting is disabled, they are marshalled again and added to the stream. If reference counting
- is enabled,
- they are written once and a reference is written in subsequent instances.
- </para>
- <para>
- By default this is set to<literal>false</literal>. Set this to
- <literal>true</literal>
- if you use
- transactions and have a lot of operations per transaction. Naturally, there is no way to
- ascertain
- a definite threshold after which reference counting should be used. It is usually a tradeoff
- between
- network speed and larger data streams, and CPU overhead in generating references. It is best to
- profile
- with this enabled and disabled to determine which is best, but one thing for certain is that if
- you do
- not use transactions, or have transactions with just one or two operations, reference counting
- ought to
- be disabled.
- </para>
- </entry>
- </row>
-
</tbody>
</tgroup>
</informaltable>
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -11,8 +11,6 @@
import org.jboss.cache.transaction.GlobalTransaction;
import javax.transaction.Transaction;
-import java.util.HashMap;
-import java.util.Map;
/**
* This context holds information specific to a method invocation.
@@ -32,7 +30,8 @@
// used to store cache peeks within the scope of a single context. Performing a cache peek can be a huge bottle neck.
// See JBCACHE-811
- private Map<Fqn, NodeSPI> peekedNodes = new HashMap<Fqn, NodeSPI>();
+ // backing out for now
+ //private Map<Fqn, NodeSPI> peekedNodes = new HashMap<Fqn, NodeSPI>();
/**
* Retrieves a node that may have previously been "peeked" within the scope of the same invocation.
@@ -41,10 +40,10 @@
* @return node, if previously peeked, or null if not.
* @since 2.1.0
*/
- public NodeSPI getPeekedNode(Fqn f)
- {
- return peekedNodes.get(f);
- }
+// public NodeSPI getPeekedNode(Fqn f)
+// {
+// return peekedNodes.get(f);
+// }
/**
* Adds a node to the previously peeked list.
@@ -53,21 +52,20 @@
* @param f fqn of node
* @since 2.1.0
*/
- public void savePeekedNode(NodeSPI n, Fqn f)
- {
- peekedNodes.put(f, n);
- }
+// public void savePeekedNode(NodeSPI n, Fqn f)
+// {
+// peekedNodes.put(f, n);
+// }
/**
* Wipe list of previously peeked nodes.
*
* @since 2.1.0
*/
- public void wipePeekedNodes()
- {
- peekedNodes.clear();
- }
-
+// public void wipePeekedNodes()
+// {
+// peekedNodes.clear();
+// }
public void setLocalRollbackOnly(boolean localRollbackOnly)
{
this.localRollbackOnly = localRollbackOnly;
Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -186,8 +186,7 @@
private transient RuntimeConfig runtimeConfig;
private String marshallerClass;
private ShutdownHookBehavior shutdownHookBehavior = ShutdownHookBehavior.DEFAULT;
- private boolean useLazyDeserialization = true;
- private boolean useReferenceCounting = false;
+ private boolean useLazyDeserialization = false;
// ------------------------------------------------------------------------------------------------------------
// SETTERS - MAKE SURE ALL SETTERS PERFORM testImmutability()!!!
@@ -492,17 +491,6 @@
this.useLazyDeserialization = useLazyDeserialization;
}
- /**
- * Sets whether reference counting should be used when marshalling remote calls.
- *
- * @since 2.1.0
- */
- public void setUseReferenceCounting(boolean b)
- {
- testImmutability("useReferenceCounting");
- useReferenceCounting = b;
- }
-
// ------------------------------------------------------------------------------------------------------------
// GETTERS
// ------------------------------------------------------------------------------------------------------------
@@ -692,16 +680,6 @@
}
/**
- * Gets whether reference counting should be used when marshalling remote calls.
- *
- * @since 2.1.0
- */
- public boolean isUseReferenceCounting()
- {
- return useReferenceCounting;
- }
-
- /**
* Returns a {@link java.net.URL} to a default JGroups configuration file.
*
* @return a default JGroups config file
@@ -774,8 +752,6 @@
if (lockParentForChildInsertRemove != that.lockParentForChildInsertRemove) return false;
- if (useReferenceCounting != that.useReferenceCounting) return false;
-
return true;
}
@@ -809,7 +785,6 @@
result = 29 * result + (runtimeConfig != null ? runtimeConfig.hashCode() : 0);
result = 29 * result + (marshallerClass != null ? marshallerClass.hashCode() : 0);
result = 29 * result + (lockParentForChildInsertRemove ? 1 : 0);
- result = 29 * result + (useReferenceCounting ? 1 : 0);
return result;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -237,19 +237,24 @@
*/
public NodeSPI peekNode(InvocationContext ctx, Fqn f, boolean forceRefresh, boolean includeDeletedNodes, boolean includeInvalidNodes)
{
- NodeSPI n;
- if (forceRefresh || (n = ctx.getPeekedNode(f)) == null)
- {
- n = cache.peek(f, true, true);
- // put this in the invocation cache
- ctx.savePeekedNode(n, f);
- }
+ return cache.peek(f, includeDeletedNodes, includeInvalidNodes);
- if (n != null)
- {
- if (!includeDeletedNodes && n.isDeleted()) return null;
- if (!includeInvalidNodes && !n.isValid()) return null;
- }
- return n;
+ // Disabling this for now, until we can prove that it is in fact beneficial.
+ // preliminary profiling tests show that it is not.
+
+// NodeSPI n;
+// if (forceRefresh || (n = ctx.getPeekedNode(f)) == null)
+// {
+// n = cache.peek(f, true, true);
+// // put this in the invocation cache
+// ctx.savePeekedNode(n, f);
+// }
+//
+// if (n != null)
+// {
+// if (!includeDeletedNodes && n.isDeleted()) return null;
+// if (!includeInvalidNodes && !n.isValid()) return null;
+// }
+// return n;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -108,7 +108,8 @@
}
}
- ctx.wipePeekedNodes();
+ // JBCACHE-811 - backed out for now
+// ctx.wipePeekedNodes();
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -48,7 +48,7 @@
for (Object o : args)
{
counter++;
- if (MarshalledValueHelper.excludeFromMarshalledValueWrapping(o) || isInternalCollection(counter, id))
+ if (o == null || MarshalledValueHelper.isTypeExcluded(o.getClass()) || isInternalCollection(counter, id))
{
replacementArgs[counter] = o;
}
@@ -113,8 +113,8 @@
for (Object key : m.keySet())
{
Object value = m.get(key);
- copy.put(MarshalledValueHelper.excludeFromMarshalledValueWrapping(key) ? key : createAndAddMarshalledValue(key, marshalledValues, ctx),
- MarshalledValueHelper.excludeFromMarshalledValueWrapping(value) ? value : createAndAddMarshalledValue(value, marshalledValues, ctx));
+ copy.put((key == null || MarshalledValueHelper.isTypeExcluded(key.getClass())) ? key : createAndAddMarshalledValue(key, marshalledValues, ctx),
+ (value == null || MarshalledValueHelper.isTypeExcluded(value.getClass())) ? value : createAndAddMarshalledValue(value, marshalledValues, ctx));
}
return copy;
}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -57,10 +57,6 @@
{
this.useRegionBasedMarshalling = configuration.isUseRegionBasedMarshalling();
this.defaultInactive = configuration.isInactiveOnStartup();
-
- // ensure that if we are using CacheMarshaller200 - i.e., using replication version of 2.0.0 - reference counting is
- // enabled, since this is always enabled in JBC 2.0.0.
- this.useRefs = configuration.isUseReferenceCounting() || getClass().equals(CacheMarshaller200.class);
}
protected void initLogger()
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -66,6 +66,8 @@
public CacheMarshaller200()
{
initLogger();
+ // enabled, since this is always enabled in JBC 2.0.0.
+ useRefs = true;
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller210.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller210.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller210.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -19,6 +19,9 @@
public CacheMarshaller210()
{
initLogger();
+ // disabled, since this is always disabled in JBC 2.0.0.
+ // Java ObjectOutputStreams will have it's own built-in ref counting. No need to repeat this.
+ useRefs = false;
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MarshalledValueHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MarshalledValueHelper.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MarshalledValueHelper.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -27,30 +27,7 @@
type.equals(Void.class) || type.equals(Boolean.class) || type.equals(Character.class) ||
type.equals(Byte.class) || type.equals(Short.class) || type.equals(Integer.class) ||
type.equals(Long.class) || type.equals(Float.class) || type.equals(Double.class) ||
- (type.isArray() && isTypeExcluded(type.getComponentType()));
- }
-
- /**
- * Tests if the type is a JBoss Cache system type, and hence excluded from MarshalledValue wrapping.
- *
- * @param type type to test. Should not be null.
- * @return true if this is a system type.
- */
- public static boolean isSystemType(Class type)
- {
- return type.equals(Fqn.class) || type.equals(GlobalTransaction.class) || type.equals(Address.class) ||
+ (type.isArray() && isTypeExcluded(type.getComponentType())) || type.equals(Fqn.class) || type.equals(GlobalTransaction.class) || type.equals(Address.class) ||
type.equals(MethodCall.class) || type.equals(MarshalledValue.class);
}
-
- /**
- * Tests if an object should be excluded from being wrapped as a MarshalledValue. Excluded if the object is null or
- * if it's type returns true when passed into {@link #isTypeExcluded(Class)} or {@link #isSystemType(Class)}.
- *
- * @param object object to test
- * @return true if it is to be excluded from MarshalledValue wrapping.
- */
- public static boolean excludeFromMarshalledValueWrapping(Object object)
- {
- return object == null || isSystemType(object.getClass()) || isTypeExcluded(object.getClass());
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java 2008-02-06 01:05:04 UTC (rev 5305)
+++ core/trunk/src/test/java/org/jboss/cache/profiling/AbstractProfileTest.java 2008-02-06 01:19:52 UTC (rev 5306)
@@ -24,7 +24,6 @@
{
Configuration cfg = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.REPL_SYNC);
cache = new DefaultCacheFactory().createCache(cfg, false);
- cfg.setUseReferenceCounting(false);
}
@AfterTest
More information about the jbosscache-commits
mailing list