mkwan 2003/02/27 11:56:05
Modified: java/src/org/apache/xalan/lib/sql Tag: XSLTC_DTM
DTMDocument.java
java/src/org/apache/xalan/xsltc/compiler Tag: XSLTC_DTM
Constants.java
java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
SAXImpl.java
java/src/org/apache/xalan/xsltc/runtime Tag: XSLTC_DTM
AttributeList.java
java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
DTMDefaultBase.java DTMStringPool.java
java/src/org/apache/xml/dtm/ref/sax2dtm Tag: XSLTC_DTM
SAX2DTM.java SAX2DTM2.java
java/src/org/apache/xml/utils Tag: XSLTC_DTM
SuballocatedIntVector.java
Log:
XSLTC_DTM performance work
Improvement for RTF. These changes improve the performance
for stylesheets which create and throw away many small RTFs.
Make the sizes of all internal storage units used by SAXImpl configurable.
These include SuballocatedIntVector, DTMStringPool, IntStack and
FastStringBuffer.
The chain size of DTMStringPool and the number of blocks in
SuballocatedIntVector
can now be passed in the constructor. These sizes are set to smaller values in
the RTF case.
The default RTF size is changed to 32. There is also a change in the XSLTC
AttributeList class to use on-demand memory allocation for the internal
vectors.
The vectors are only allocated when there is an attribute.
Revision Changes Path
No revision
No revision
1.8.2.4 +1 -1
xml-xalan/java/src/org/apache/xalan/lib/sql/DTMDocument.java
Index: DTMDocument.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/DTMDocument.java,v
retrieving revision 1.8.2.3
retrieving revision 1.8.2.4
diff -u -r1.8.2.3 -r1.8.2.4
--- DTMDocument.java 30 Jan 2003 18:41:20 -0000 1.8.2.3
+++ DTMDocument.java 27 Feb 2003 19:56:03 -0000 1.8.2.4
@@ -169,7 +169,7 @@
super(mgr, null, ident,
null, mgr.getXMLStringFactory(), true);
- m_attribute = new SuballocatedIntVector(m_initialblocksize);
+ m_attribute = new SuballocatedIntVector(DEFAULT_BLOCKSIZE);
}
/**
No revision
No revision
1.19.2.12 +2 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
Index: Constants.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
retrieving revision 1.19.2.11
retrieving revision 1.19.2.12
diff -u -r1.19.2.11 -r1.19.2.12
--- Constants.java 25 Feb 2003 19:14:48 -0000 1.19.2.11
+++ Constants.java 27 Feb 2003 19:56:03 -0000 1.19.2.12
@@ -504,5 +504,5 @@
public static final String FALLBACK_CLASS
= "org.apache.xalan.xsltc.compiler.Fallback";
- public static final int RTF_INITIAL_SIZE = 64;
+ public static final int RTF_INITIAL_SIZE = 32;
}
No revision
No revision
1.1.2.36 +10 -7
xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
Index: SAXImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java,v
retrieving revision 1.1.2.35
retrieving revision 1.1.2.36
diff -u -r1.1.2.35 -r1.1.2.36
--- SAXImpl.java 27 Feb 2003 15:49:37 -0000 1.1.2.35
+++ SAXImpl.java 27 Feb 2003 19:56:04 -0000 1.1.2.36
@@ -92,7 +92,7 @@
/* ------------------------------------------------------------------- */
/* DOMBuilder fields BEGIN */
/* ------------------------------------------------------------------- */
- private final static int INIT_STACK_LENGTH = 64;
+ //private final static int INIT_STACK_LENGTH = 64;
//private int _parentStackLength = INIT_STACK_LENGTH;
//private int[] _parentStack = new int[INIT_STACK_LENGTH];
@@ -107,7 +107,7 @@
// Stack used to keep track of what whitespace text nodes are protected
// by xml:space="preserve" attributes and which nodes that are not.
- private int[] _xmlSpaceStack = new int[64];
+ private int[] _xmlSpaceStack;
private int _idx = 1;
private boolean _preserve = false;
@@ -1029,9 +1029,9 @@
* These init sizes have been tuned for the average case. Do not
* change these values unless you know exactly what you're doing.
*/
- static private final int SMALL_TEXT_SIZE = 1024;
- static private final int DEFAULT_INIT_SIZE = 1024;
- static private final int DEFAULT_TEXT_FACTOR = 10;
+ //static private final int SMALL_TEXT_SIZE = 1024;
+ //static private final int DEFAULT_INIT_SIZE = 1024;
+ //static private final int DEFAULT_TEXT_FACTOR = 10;
/**
* Construct a SAXImpl object using the default block size.
@@ -1042,7 +1042,7 @@
boolean doIndexing)
{
this(mgr, saxSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
- doIndexing, m_initialblocksize);
+ doIndexing, DEFAULT_BLOCKSIZE);
}
/**
@@ -1056,6 +1056,9 @@
super(mgr, saxSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
doIndexing, blocksize);
_size = blocksize;
+
+ // Use a smaller size for the space stack if the blocksize is small
+ _xmlSpaceStack = new int[blocksize <= 64 ? 4 : 64];
//initialize(size, size < 128 ? SMALL_TEXT_SIZE
// : size * DEFAULT_TEXT_FACTOR);
No revision
No revision
1.4.14.4 +35 -9
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AttributeList.java
Index: AttributeList.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AttributeList.java,v
retrieving revision 1.4.14.3
retrieving revision 1.4.14.4
diff -u -r1.4.14.3 -r1.4.14.4
--- AttributeList.java 30 Jan 2003 18:41:48 -0000 1.4.14.3
+++ AttributeList.java 27 Feb 2003 19:56:04 -0000 1.4.14.4
@@ -80,11 +80,13 @@
* AttributeList constructor
*/
public AttributeList() {
+ /*
_attributes = new Hashtable();
_names = new Vector();
_values = new Vector();
_qnames = new Vector();
_uris = new Vector();
+ */
_length = 0;
}
@@ -100,6 +102,20 @@
}
}
}
+
+ /**
+ * Allocate memory for the AttributeList
+ * %OPT% Use on-demand allocation for the internal vectors. The memory
+ * is only allocated when there is an attribute. This reduces the cost
+ * of creating many small RTFs.
+ */
+ private void alloc() {
+ _attributes = new Hashtable();
+ _names = new Vector();
+ _values = new Vector();
+ _qnames = new Vector();
+ _uris = new Vector();
+ }
/**
* SAX2: Return the number of attributes in the list.
@@ -187,9 +203,13 @@
* SAX2: Look up an attribute's value by qname.
*/
public String getValue(String qname) {
- final Integer obj = (Integer)_attributes.get(qname);
- if (obj == null) return null;
- return(getValue(obj.intValue()));
+ if (_attributes != null) {
+ final Integer obj = (Integer)_attributes.get(qname);
+ if (obj == null) return null;
+ return(getValue(obj.intValue()));
+ }
+ else
+ return null;
}
/**
@@ -203,6 +223,10 @@
* Adds an attribute to the list
*/
public void add(String qname, String value) {
+ // Initialize the internal vectors at the first usage.
+ if (_attributes == null)
+ alloc();
+
// Stuff the QName into the names vector & hashtable
Integer obj = (Integer)_attributes.get(qname);
if (obj == null) {
@@ -230,11 +254,13 @@
*/
public void clear() {
_length = 0;
- _attributes.clear();
- _names.removeAllElements();
- _values.removeAllElements();
- _qnames.removeAllElements();
- _uris.removeAllElements();
+ if (_attributes != null) {
+ _attributes.clear();
+ _names.removeAllElements();
+ _values.removeAllElements();
+ _qnames.removeAllElements();
+ _uris.removeAllElements();
+ }
}
}
No revision
No revision
1.28.2.14 +20 -11
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java
Index: DTMDefaultBase.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java,v
retrieving revision 1.28.2.13
retrieving revision 1.28.2.14
diff -u -r1.28.2.13 -r1.28.2.14
--- DTMDefaultBase.java 3 Feb 2003 19:12:05 -0000 1.28.2.13
+++ DTMDefaultBase.java 27 Feb 2003 19:56:04 -0000 1.28.2.14
@@ -123,11 +123,17 @@
*/
protected int[][][] m_elemIndexes;
- /** The default initial block size of the node arrays */
- protected static final int m_initialblocksize = 512; // favor small docs.
-
+ /** The default block size of the node arrays */
+ protected static final int DEFAULT_BLOCKSIZE = 512; // favor small docs.
+
+ /** The number of blocks for the node arrays */
+ protected static final int DEFAULT_NUMBLOCKS = 32;
+
+ /** The number of blocks used for small documents & RTFs */
+ protected static final int DEFAULT_NUMBLOCKS_SMALL = 4;
+
/** The block size of the node arrays */
- protected final int m_blocksize;
+ //protected final int m_blocksize;
/**
* The value to use when the information has not been built yet.
@@ -200,7 +206,7 @@
XMLStringFactory xstringfactory, boolean doIndexing)
{
this(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
- doIndexing, m_initialblocksize);
+ doIndexing, DEFAULT_BLOCKSIZE);
}
/**
@@ -222,12 +228,15 @@
XMLStringFactory xstringfactory, boolean doIndexing,
int blocksize)
{
- m_blocksize = blocksize;
- m_exptype = new SuballocatedIntVector(blocksize);
- m_firstch = new SuballocatedIntVector(blocksize);
- m_nextsib = new SuballocatedIntVector(blocksize);
- m_prevsib = new SuballocatedIntVector(blocksize);
- m_parent = new SuballocatedIntVector(blocksize);
+ //m_blocksize = blocksize;
+ int numblocks = (blocksize <= 64) ? DEFAULT_NUMBLOCKS_SMALL :
+ DEFAULT_NUMBLOCKS;
+
+ m_exptype = new SuballocatedIntVector(blocksize, numblocks);
+ m_firstch = new SuballocatedIntVector(blocksize, numblocks);
+ m_nextsib = new SuballocatedIntVector(blocksize, numblocks);
+ m_prevsib = new SuballocatedIntVector(blocksize, numblocks);
+ m_parent = new SuballocatedIntVector(blocksize, numblocks);
m_mgr = mgr;
if(mgr instanceof DTMManagerDefault)
1.4.12.3 +12 -2
xml-xalan/java/src/org/apache/xml/dtm/ref/DTMStringPool.java
Index: DTMStringPool.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMStringPool.java,v
retrieving revision 1.4.12.2
retrieving revision 1.4.12.3
diff -u -r1.4.12.2 -r1.4.12.3
--- DTMStringPool.java 30 Jan 2003 18:41:52 -0000 1.4.12.2
+++ DTMStringPool.java 27 Feb 2003 19:56:04 -0000 1.4.12.3
@@ -98,16 +98,26 @@
IntVector m_hashChain;
public static final int NULL=-1;
- public DTMStringPool()
+ /**
+ * Create a DTMStringPool using the given chain size
+ *
+ * @param chainSize The size of the hash chain vector
+ */
+ public DTMStringPool(int chainSize)
{
m_intToString=new Vector();
- m_hashChain=new IntVector(512);
+ m_hashChain=new IntVector(chainSize);
removeAllElements();
// -sb Add this to force empty strings to be index 0.
stringToIndex("");
}
+ public DTMStringPool()
+ {
+ this(512);
+ }
+
public void removeAllElements()
{
m_intToString.removeAllElements();
No revision
No revision
1.28.2.19 +28 -8
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java
Index: SAX2DTM.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/SAX2DTM.java,v
retrieving revision 1.28.2.18
retrieving revision 1.28.2.19
diff -u -r1.28.2.18 -r1.28.2.19
--- SAX2DTM.java 18 Feb 2003 19:08:47 -0000 1.28.2.18
+++ SAX2DTM.java 27 Feb 2003 19:56:04 -0000 1.28.2.19
@@ -116,7 +116,7 @@
* Made protected rather than private so SAX2RTFDTM can access it.
*/
//private FastStringBuffer m_chars = new FastStringBuffer(13, 13);
- protected FastStringBuffer m_chars = new FastStringBuffer(10, 13);
+ protected FastStringBuffer m_chars;
/** This vector holds offset and length data.
*/
@@ -125,7 +125,7 @@
/** The parent stack, needed only for construction.
* Made protected rather than private so SAX2RTFDTM can access it.
*/
- transient protected IntStack m_parents = new IntStack();
+ transient protected IntStack m_parents;
/** The current previous node, needed only for construction time.
* Made protected rather than private so SAX2RTFDTM can access it.
@@ -141,7 +141,7 @@
/** Namespace support, only relevent at construction time.
* Made protected rather than private so SAX2RTFDTM can access it.
*/
- transient protected IntStack m_contextIndexes = new IntStack();
+ transient protected IntStack m_contextIndexes;
/** Type of next characters() event within text block in prgress. */
transient protected int m_textType = DTM.TEXT_NODE;
@@ -165,7 +165,7 @@
protected DTMTreeWalker m_walker = new DTMTreeWalker();
/** pool of string values that come as strings. */
- protected DTMStringPool m_valuesOrPrefixes = new DTMStringPool();
+ protected DTMStringPool m_valuesOrPrefixes;
/** End document has been reached.
* Made protected rather than private so SAX2RTFDTM can access it.
@@ -263,7 +263,7 @@
{
this(mgr, source, dtmIdentity, whiteSpaceFilter,
- xstringfactory, doIndexing, m_initialblocksize);
+ xstringfactory, doIndexing, DEFAULT_BLOCKSIZE);
}
/**
@@ -290,15 +290,35 @@
super(mgr, source, dtmIdentity, whiteSpaceFilter,
xstringfactory, doIndexing, blocksize);
-
+ // %OPT% Use smaller sizes for all internal storage units when
+ // the blocksize is small. This reduces the cost of creating an RTF.
+ if (blocksize <= 64)
+ {
+ m_data = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS_SMALL);
+ m_dataOrQName = new SuballocatedIntVector(blocksize,
DEFAULT_NUMBLOCKS_SMALL);
+ m_valuesOrPrefixes = new DTMStringPool(16);
+ m_chars = new FastStringBuffer(7, 10);
+ m_contextIndexes = new IntStack(4);
+ m_parents = new IntStack(4);
+ }
+ else
+ {
+ m_data = new SuballocatedIntVector(blocksize, DEFAULT_NUMBLOCKS);
+ m_dataOrQName = new SuballocatedIntVector(blocksize,
DEFAULT_NUMBLOCKS);
+ m_valuesOrPrefixes = new DTMStringPool();
+ m_chars = new FastStringBuffer(10, 13);
+ m_contextIndexes = new IntStack();
+ m_parents = new IntStack();
+ }
+
// %REVIEW% Initial size pushed way down to reduce weight of RTFs
// (I'm not entirely sure 0 would work, so I'm playing it safe for now.)
//m_data = new SuballocatedIntVector(doIndexing ? (1024*2) : 512, 1024);
- m_data = new SuballocatedIntVector(blocksize);
+ //m_data = new SuballocatedIntVector(blocksize);
m_data.addElement(0); // Need placeholder in case index into here must
be <0.
- m_dataOrQName = new SuballocatedIntVector(blocksize);
+ //m_dataOrQName = new SuballocatedIntVector(blocksize);
//
m_useSourceLocationProperty=org.apache.xalan.processor.TransformerFactoryImpl.m_source_location;
m_useSourceLocationProperty = m_source_location;
1.1.2.20 +1 -1
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java
Index: SAX2DTM2.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java,v
retrieving revision 1.1.2.19
retrieving revision 1.1.2.20
diff -u -r1.1.2.19 -r1.1.2.20
--- SAX2DTM2.java 26 Feb 2003 18:03:25 -0000 1.1.2.19
+++ SAX2DTM2.java 27 Feb 2003 19:56:04 -0000 1.1.2.20
@@ -1737,7 +1737,7 @@
{
this(mgr, source, dtmIdentity, whiteSpaceFilter,
- xstringfactory, doIndexing, m_initialblocksize);
+ xstringfactory, doIndexing, DEFAULT_BLOCKSIZE);
}
/**
No revision
No revision
1.6.10.4 +18 -14
xml-xalan/java/src/org/apache/xml/utils/SuballocatedIntVector.java
Index: SuballocatedIntVector.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xml/utils/SuballocatedIntVector.java,v
retrieving revision 1.6.10.3
retrieving revision 1.6.10.4
diff -u -r1.6.10.3 -r1.6.10.4
--- SuballocatedIntVector.java 29 Jan 2003 22:03:29 -0000 1.6.10.3
+++ SuballocatedIntVector.java 27 Feb 2003 19:56:05 -0000 1.6.10.4
@@ -85,8 +85,11 @@
/** Bitwise addressing (much faster than div/remainder */
protected int m_SHIFT, m_MASK;
- /** Number of blocks to (over)allocate by */
- protected int m_numblocks=32;
+ /** The default number of blocks to (over)allocate by */
+ protected static final int NUMBLOCKS_DEFAULT = 32;
+
+ /** The number of blocks to (over)allocate by */
+ protected int m_numblocks = NUMBLOCKS_DEFAULT;
/** Array of arrays of ints */
protected int m_map[][];
@@ -115,36 +118,37 @@
}
/**
- * Construct a IntVector, using the given block size. For
- * efficiency, we will round the requested size off to a power of
- * two.
+ * Construct a IntVector, using the given block size and number
+ * of blocks. For efficiency, we will round the requested size
+ * off to a power of two.
*
* @param blocksize Size of block to allocate
+ * @param numblocks Number of blocks to allocate
* */
- public SuballocatedIntVector(int blocksize)
+ public SuballocatedIntVector(int blocksize, int numblocks)
{
//m_blocksize = blocksize;
for(m_SHIFT=0;0!=(blocksize>>>=1);++m_SHIFT)
;
m_blocksize=1<<m_SHIFT;
m_MASK=m_blocksize-1;
-
+ m_numblocks = numblocks;
+
m_map0=new int[m_blocksize];
- m_map = new int[m_numblocks][];
+ m_map = new int[numblocks][];
m_map[0]=m_map0;
m_buildCache = m_map0;
m_buildCacheStartIndex = 0;
}
- /** We never _did_ use the increasesize parameter, so I'm phasing
- * this constructor out.
+ /** Construct a IntVector, using the given block size and
+ * the default number of blocks (32).
*
- * @deprecated use SuballocatedIntVector(int)
- * @see SuballocatedIntVector(int)
+ * @param blocksize Size of block to allocate
* */
- public SuballocatedIntVector(int blocksize,int increasesize)
+ public SuballocatedIntVector(int blocksize)
{
- this(blocksize);
+ this(blocksize, NUMBLOCKS_DEFAULT);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]