Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML processing performance issue in high concurrency scenarios #101

Open
iddo opened this issue Jan 3, 2013 · 1 comment
Open

XML processing performance issue in high concurrency scenarios #101

iddo opened this issue Jan 3, 2013 · 1 comment
Labels
E4X Issues related to the (deprecated) ECMAScript for XML (E4X/ECMA-357) standard Performance Issues related to the performance of the Rhino engine

Comments

@iddo
Copy link

iddo commented Jan 3, 2013

Using Rhino in a high concurrency situation with JavaScript that contains XML markup (I believe it's called E4X, or ECMAScript) seems to be affected by a hard-coded resource pool due to 26ee7ee

Sample E4X Script:

var myXml = <root><someelement></someelement></root>

In our test environment we got multiple thread with the following stack-trace:

"pool-62-thread-59" - Thread t@174
   java.lang.Thread.State: BLOCKED
at org.mozilla.javascript.xmlimpl.XmlProcessor.getDocumentBuilderFromPool(XmlProcessor.java:182)
- waiting to lock <71a4d2e4> (a org.mozilla.javascript.xmlimpl.XmlProcessor) owned by "pool-62-thread-19" t@134
at org.mozilla.javascript.xmlimpl.XmlProcessor.toXml(XmlProcessor.java:255)
at org.mozilla.javascript.xmlimpl.XmlNode.createElement(XmlNode.java:119)
at org.mozilla.javascript.xmlimpl.XMLLibImpl.parse(XMLLibImpl.java:444)
at org.mozilla.javascript.xmlimpl.XMLLibImpl.ecmaToXml(XMLLibImpl.java:477)
at org.mozilla.javascript.xmlimpl.XMLObjectImpl.ecmaToXml(XMLObjectImpl.java:838)
at org.mozilla.javascript.xmlimpl.XML.jsConstructor(XML.java:229)
at org.mozilla.javascript.xmlimpl.XMLObjectImpl.execIdCall(XMLObjectImpl.java:626)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
at org.mozilla.javascript.BaseFunction.construct(BaseFunction.java:374)
at org.mozilla.javascript.ScriptRuntime.newObject(ScriptRuntime.java:2440)
at <truncated due to irrelevancy>
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Locked ownable synchronizers:
- locked <6a3fc851> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

Which caused the CPU to be under-utilized at 33%.

Since there's no way of knowing exactly how Rhino will be used I suggest letting the developer configure the size of this pool (or providing other methods to control this bottleneck).

@mbd-dbc-dk
Copy link
Contributor

Hi there.

For some more discussion of this subject, check this pull request:
#9

@p-bakker p-bakker added E4X Issues related to the (deprecated) ECMAScript for XML (E4X/ECMA-357) standard Performance Issues related to the performance of the Rhino engine labels Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E4X Issues related to the (deprecated) ECMAScript for XML (E4X/ECMA-357) standard Performance Issues related to the performance of the Rhino engine
Projects
None yet
Development

No branches or pull requests

3 participants