You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ricky Ho <ri...@cisco.com> on 2003/02/21 02:52:19 UTC

Why Pull-Parser faster ? - Still NO answer

Just between SAX and XPP ....

If SAX can be stopped anytime by throwing an exception, this means the 
application can control when to stop.  And if XPP is not skipping 
whitespace ...

Why XPP is faster than SAX ??

Best regards,
Ricky

>Mailing-List: contact axis-user-help@ws.apache.org; run by ezmlm
>Reply-To: axis-user@ws.apache.org
>list-help: <ma...@ws.apache.org>
>list-unsubscribe: <ma...@ws.apache.org>
>list-post: <ma...@xml.apache.org>
>Delivered-To: mailing list axis-user@ws.apache.org
>Date: Thu, 20 Feb 2003 20:34:06 -0500
>From: Aleksander Slominski <as...@cs.indiana.edu>
>User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2) 
>Gecko/20021126
>X-Accept-Language: en-us, en
>To: axis-user@ws.apache.org
>Subject: Re: Why Pull-Parser faster ?
>X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
>
>Brain, Jim wrote:
>
>>In XPP (XML Pull Parser), the idea is like SAX, where no in-memory model is
>>kept, and the code is basically scanning through the XML.  However, As Anne
>>stated, you can stop in the middle of a parse in XPP, and continue later, or
>>start over, or whatever.  Also, most XPP parsers throw away some of the XML
>>information, like extra whitespace in order to gain more performance.  If
>>you have to scan the entire XML feed, XPP is still faster, because it throws
>>away information, but your most pronounced speedup in XPP is if you do a
>>conditional partial parse of the doc (It's much harder, if possible at all
>>to do a conditional partial parse using SAX.)
>>
>>So, DOM is memory and 1+ scan, all XML entities (once by the parser, more by
>>your app)
>>SAX is no memory and 1 scan, all XML entities
>>XPP is no memory and 0-1 scan , not all XML entities (your app scans as it
>>desires)
>>
>>Examples of things XPP throws away:
>>
>><jim>
>>
>><brain>Hi there</brain>
>>
>></jim>
>>
>>In DOM and SAX, the whitespace between jim and brain is represented in the
>>model, because it might be necessary, but in XPP, the document gets
>>represented as:
>>
>><jim><brain>Hi there</brain></jim>
>>
>>Reason:  XPP is tuned for SOAP and structured XML work, where the whitespace
>>and CRLF marks can be assumed to be there for prettiness only, and have no
>>code value.
>>
>hi Jim,
>
>what you describe i think you refer to handling of element content when 
>mixed content is disabled. that was possible in XPP2 but is no longer case 
>in XPP3 that implements XmlPull API and XPP3 does not throw anything away 
>but allows you to skip over if call next() method but do not retrieve any 
>event information.
>
>in XPP2 when optional mode to disable mixed content was activated you 
>would get input as described in the example you gave.
>
>in XmlPull to achieve similar result you can use nextText()/nextTag() to 
>skip whitespaces if you desire so but you can also see all XML infoset 
>events in input any time you want (just use next())
>
>thanks,
>
>alek
>
>--
>"Mr. Pauli, we in the audience are all agreed that your theory is crazy. 
>What divides us is whether it is crazy enough to be true." Niels H. D. Bohr
>
>


Re: Why Pull-Parser faster ? - Still NO answer

Posted by Ricky Ho <ri...@cisco.com>.
Tom, my comments embedded

>My impression (until this discussion started) was that both are linear
>in input, able to quit at any point, but the difference was three-fold
>   (a) since SAX events are context-independent, and the logic of XML
>often depends on what has gone before it, event handlers must often
>effectively figure out the program state ("Oh, here's a number-tag;
>what was I doing?") where XPP encodes much of the program state in
>the program counter ("at this point, I'd better be reading a number.")
>That gives XPP a little more speed, a little more readability; the
>latter seems more important, really.

I'm seeing the same thing.  Just a little (insignificant) speed ...

>   (b) since SAX is data-driven, but the basic language structure is
>demand-driven, some possible designs are awkward: if you want to read
>a part of a file and then process it and do something else (say, wait
>for a user input) before you read the next part of the file, you must
>put the SAX handling into a separate thread and suspend it. Again, XPP
>wins a bit in speed, a bit in readability (and writability.

Why can't you wait within the callback method of a SAXHandler of the same 
thread ?  Why a separate thread need to be created ?

>   (c) since XPP can effectively skip over subtrees, there is at least
>in principle the possibility of a sublinear implementation working on
>tree-structured data, not necessarily DOM. I've no idea if anybody
>actually does this, but you can certainly serialize a tree in which
>each start-tag (for all or some start-tags) stores the position of
>the matching end-tag, so that skipping is constant-time and data access
>to a given tree-location is ...well, not quite logarithmic, but O(D*K)
>where D would be the depth of the item you seek and K would be the
>branching factor for the tree. (Of course you can do better with more
>complex representations, all of which will be invisible to the program
>calling the XPP parser.) Something like that, if I'm awake yet.

XPP can skip over those element that are "exactly once", but not "optional" 
or "multiple" which requires XPP to "read" and "check" before 
"next".  Similarly, in SAX, your handler will check and return 
immediately.  Again similar workload and insignificant difference.

For the start tag storing the position of end tag, do you need to parse 
through the whole document at least once.  DOM approach ??

Rgds, Ricky


Re: Are JAXRPC, XMLPull incompatible? was Re: Why Pull-Parser faster ?

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
I went back to the spec, and as far as I can see now you're right - the 
JAX-RPC spec does *not* force use of SAX. The reference implementation 
is built around SAX (as is Axis), but that's not the same thing at all. 
I apologize for the misinformation on this - it may have been because 
it's been promised that JAX-RPC will support JAXB, and JAXB requires SAX 
support (it allows other alternatives as implementation-dependent 
optional features, but requires that all implementations include SAX 
support).

Thanks for pointing this out, Brian. The spec is a lot more general than 
I remembered. And I'm wearing egg on my face for not double checking 
before pointing the finger... is egg good for the complexion? ;-)

On the continuing discussion of push vs pull parsing and which is 
faster, I'm going to refrain from any more emails on this topic any time 
soon. For those who are interested in actual performance results for 
SAX-based deserialization of objects (data binding unmarshalling) vs an 
experimental pull parser approach see my article at 
http://www-106.ibm.com/developerworks/library/x-databdopt2/

  - Dennis

Brian Ewins wrote:

> Going back (way back) into this thread -
>
> Anne Thomas Manes wrote:
> "We had another discussion on this list [1] recently about 
> performance. The JAX-RPC spec forces the use of SAX, which isn't the 
> most efficient way to parse structured messages. 
> http://marc.theaimsgroup.com/?l=axis-user&m=104429792424850&w=2"
>
> In the email referred to, Dennis Sosnoski says:
> "For instance, JAX-RPC is based on SAX parsing which is
> pretty horrible for structured data - you have to maintain state in your
> handlers,..."
>
> But the JAX-RPC spec says:
> "Note that the type mapping framework does not require an 
> implementation of a JAXRPC runtime system to use a specific XML 
> processing mechanism. For example, a JAXRPC implementation may use a 
> streaming pull parser for performance efficient XML processing. DOM or 
> SAX based deserializers may still be developed and plugged into the 
> extensible type mapping framework provided by this JAX-RPC 
> implementation." (jaxrpc-1.0-fr, Section 15.2)
>
> So my question is - is the spec right here? Or are Dennis and Anne 
> referring to some intrinsic difficulty with the JAX-RPC apis that 
> prevent them being used on top of XMLPULL?
>
> Cheers,
>     Baz
>


Are JAXRPC, XMLPull incompatible? was Re: Why Pull-Parser faster ?

Posted by Brian Ewins <Br...@btinternet.com>.
Going back (way back) into this thread -

Anne Thomas Manes wrote:
"We had another discussion on this list [1] recently about performance. 
The JAX-RPC spec forces the use of SAX, which isn't the most efficient 
way to parse structured messages. 
http://marc.theaimsgroup.com/?l=axis-user&m=104429792424850&w=2"

In the email referred to, Dennis Sosnoski says:
"For instance, JAX-RPC is based on SAX parsing which is
pretty horrible for structured data - you have to maintain state in your
handlers,..."

But the JAX-RPC spec says:
"Note that the type mapping framework does not require an implementation 
of a JAXRPC runtime system to use a specific XML processing mechanism. 
For example, a JAXRPC implementation may use a streaming pull parser for 
performance efficient XML processing. DOM or SAX based deserializers may 
still be developed and plugged into the extensible type mapping 
framework provided by this JAX-RPC implementation." (jaxrpc-1.0-fr, 
Section 15.2)

So my question is - is the spec right here? Or are Dennis and Anne 
referring to some intrinsic difficulty with the JAX-RPC apis that 
prevent them being used on top of XMLPULL?

Cheers,
	Baz


JBoss-net (Axis) <-> MS.Net | Integration

Posted by Ricardo Ramalho <rr...@tekever.com>.
Dear people,

I'm writing you because of a difficulty in MS.NET/JBoss-net.

I'm trying to integrate a client app built on Microsoft's .NET with  JBoss
using JBoss-net. But i'm having some weird problems doing so.

I successfully installed JBoss-net and deployed the Session Beans i wanted
to have available as Web-Services.

Next, i can configure the Web-Services inside Visual Studio.NET, and those
methods get recognised by the IDE. The application compiles successfully.

However, something really wierd starts to happen when i run the application
and it starts calling the Web-Services. The .net app freezes when i make my
second Web-Service invocation (yes... the first time a web-services is
invocated it runs ok.... the second method, whatever method, i call it just
freezes the app). JBoss then throws a SocketTimeOutException... But if i
wait a little bit (4 seconds or so...) between calls to web-services, it
works quite allright... I just don't get it. :(

I just dont understand this wierd problem.

Thanks in advance for any help you can give me.

------------------
Ricardo Ramalho
www.tekever.com



Re: Why Pull-Parser faster ? - Still NO answer

Posted by Tom Myers <to...@dreamscape.com>.
Ricky Ho wrote:

> Just between SAX and XPP ....
>
> If SAX can be stopped anytime by throwing an exception, this means the
> application can control when to stop.  And if XPP is not skipping
> whitespace ...
>
> Why XPP is faster than SAX ??

My impression (until this discussion started) was that both are linear
in input, able to quit at any point, but the difference was three-fold
   (a) since SAX events are context-independent, and the logic of XML
often depends on what has gone before it, event handlers must often
effectively figure out the program state ("Oh, here's a number-tag;
what was I doing?") where XPP encodes much of the program state in
the program counter ("at this point, I'd better be reading a number.")
That gives XPP a little more speed, a little more readability; the
latter seems more important, really.
   (b) since SAX is data-driven, but the basic language structure is
demand-driven, some possible designs are awkward: if you want to read
a part of a file and then process it and do something else (say, wait
for a user input) before you read the next part of the file, you must
put the SAX handling into a separate thread and suspend it. Again, XPP
wins a bit in speed, a bit in readability (and writability.
   (c) since XPP can effectively skip over subtrees, there is at least
in principle the possibility of a sublinear implementation working on
tree-structured data, not necessarily DOM. I've no idea if anybody
actually does this, but you can certainly serialize a tree in which
each start-tag (for all or some start-tags) stores the position of
the matching end-tag, so that skipping is constant-time and data access
to a given tree-location is ...well, not quite logarithmic, but O(D*K)
where D would be the depth of the item you seek and K would be the
branching factor for the tree. (Of course you can do better with more
complex representations, all of which will be invisible to the program
calling the XPP parser.) Something like that, if I'm awake yet.

   Is any of this true? I really don't know. Do I need more coffee? Yes.

Tom Myers



Re: Why Pull-Parser faster ? - Still NO answer

Posted by Aleksander Slominski <as...@cs.indiana.edu>.
Ricky Ho wrote:

> Just between SAX and XPP ....
>
> If SAX can be stopped anytime by throwing an exception, this means the 
> application can control when to stop.  And if XPP is not skipping 
> whitespace ...
>
> Why XPP is faster than SAX ?? 

hi,

not sure if these two can be compared. SAX is just an API with many 
implementations. XPP2 is also API (with two implementations) and XmlPull 
API has 3 implementations (and XPP3 is one of them). even if you run 
some tests (like 
http://www.extreme.indiana.edu/~aslom/xpp_sax2bench/results.html) how it 
will work for you will ultimately depend on implementation used, 
hardware and software environment (OS, memory, CPU, version of Java), 
your application and on what XML input you are processing.

however i guess your question is if there is something in XML push or 
pull parsing (SAX or XmlPull  are just examples of such APIs) that would 
make one faster than another? i think that both APIs have similar 
performance capabilities and choice to use push or pull parsing should 
be dictated by you need to use streaming parsing (if you do not want 
streaming than maybe some DOM-like API is better) and how your 
application is processing XML.

i would say that for if you need to do filtering and/or use state 
machines then push parsing code is easier and when you need to convert 
XML to other representation pull parsing code is more natural IMHO - i 
have discussed some of those issues and some others in this technical 
report: http://www.extreme.indiana.edu/xgws/papers/xml_push_pull/  where 
i makes point that  pull and push are actually complementary approaches 
and can be used *together* even on the same input (it describes XPP2 API 
but most of it applies to XmlPull API as well).

hope you find it useful in addressing your concerns.

thanks,

alek

-- 
"Mr. Pauli, we in the audience are all agreed that your theory is crazy. 
What divides us is whether it is crazy enough to be true." Niels H. D. Bohr



Why should include encodingStyle wirh attachment?

Posted by "Jue (Jacky) Shu" <js...@uoguelph.ca>.
hi all

as far as i know, namespace http://schemas..xmlsoap.org/soap/encoding/ defines array datatype,
so when we use arry in axis, we should include "encodingStyle="http://schemas..xmlsoap.org/soap/encoding/" in wsdd.
but when we deals with attachments, why should we also includes this namespace in wsdd?
thx a lot.

Jacky