The following issue has been updated:
Updater: Brian Minchau (mailto:[EMAIL PROTECTED])
Date: Fri, 24 Sep 2004 8:29 AM
Changes:
Component changed to transformation
---------------------------------------------------------------------
For a full history of the issue, see:
http://issues.apache.org/jira/browse/XALANJ-1905?page=history
---------------------------------------------------------------------
View the issue:
http://issues.apache.org/jira/browse/XALANJ-1905
Here is an overview of the issue:
---------------------------------------------------------------------
Key: XALANJ-1905
Summary: xslt multithreaded performance
Type: Bug
Status: Open
Project: XalanJ2
Components:
Xalan-interpretive transformation
transformation
Versions:
2.6
Assignee: Xalan Developers Mailing List
Reporter: Stephen
Created: Thu, 8 Jul 2004 6:00 PM
Updated: Fri, 24 Sep 2004 8:29 AM
Environment: Operating System: Linux
Platform: PC
Description:
A program that uses a single stylesheet and multiple threads to transform
documents uses significantly more (roughly 60%) cpu time when the transform is
not synchronized. This results in confusing performance characteristics for
threaded applications (on a 2 cpu box, my application had a slight performance
degradation when I increased from 1 thread to 2 and performance degraded
significantly when the number of threads was greater than the number of cpus).
The inlined TransformerThread class can be used to demonstrate this behavior. I
ran java version "1.4.2_04" with the options '-server' and "-
Djavax.xml.transform.TransformerFactory=org.apache.xalan.xsltc.trax.TransformerF
actoryImpl". The TransformerThread program takes a stylesheet file as its first
argument (I've inlined xform.xsl which I used) and 'true'|'false' as its second
argument to specify whether or not to synchronize the transform code block.
TransformerThread class:
import java.io.*;
import java.util.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class TransformerThread extends Thread {
Templates templates;
boolean synchronize;
public static void main(String []args) throws
TransformerConfigurationException {
Templates templates = TransformerFactory.newInstance().newTemplates(
new StreamSource(new File(args[0]))
);
Thread []threads = new Thread[5];
for (int i=0; i<threads.length; ++i) {
threads[i] = new TransformerThread(
templates,
"thread-"+String.valueOf(i+1),
Boolean.valueOf(args[1]).booleanValue()
);
threads[i].start();
}
System.out.println("Threads kicked off");
System.out.flush();
for (int i=0; i<threads.length; ++i) {
try {
threads[i].join();
}
catch (InterruptedException e) { /* ignore */}
}
}
public TransformerThread(Templates templates, String name, boolean
synchronize) {
super(name);
this.templates = templates;
this.synchronize = synchronize;
}
public void run() {
byte []bytes = new String(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<foo>\n" +
" <property name=\"bar\">bar-value</property>\n" +
" <property name=\"bar\">bar-value</property>\n" +
" <property name=\"baz\">baz-value</property>\n" +
"</foo>"
).getBytes();
for (int i=0; i<2500; ++i) {
try {
StreamResult result = new StreamResult(new ByteArrayOutputStream
());
if (synchronize) {
synchronized (templates) {
templates.newTransformer().transform(
new StreamSource(new ByteArrayInputStream(bytes)),
result
);
}
}
else {
templates.newTransformer().transform(
new StreamSource(new ByteArrayInputStream(bytes)),
result
);
}
}
catch(TransformerException e) {
e.printStackTrace();
}
}
System.out.println("done: " + getName());
}
}
xform.xsl:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/foo">
<foo>
<xsl:for-each select="[EMAIL PROTECTED] != 'baz']">
<xsl:copy-of select="."/>
</xsl:for-each>
</foo>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]