saxon-help

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Mike,
I have a graph in memory and I want to build the a BFS tree view of it
for XSLT.
So I construct the BFS tree (on the order of twenty-thousand nodes,
I'd guess, but it gets built in the blink of an eye).
Then I walk the tree throwing events at an emitter (a simple emitter
that builds an RTF that I'm eventually going to grab). This step seems
to be very slow. It takes more than a minute to build the tree.
Is there some faster way? I'm tempted to make my own extensions of the
NodeInfo classes that support tree construction so I can just build
the graph in the first pass. But I wonder if there's a simpler answer
that I'm overlooking?
Be seeing you,
norm
- --
Norman Walsh <ndw@...> | A man should have any number of little
http://nwalsh.com/ | aims about which he should be conscious
| and for which he should have names, but
| he should have neither name for, nor
| consciousness concerning, the main aim
| of his life.--Samuel Butler (II)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.7 <http://mailcrypt.sourceforge.net/&gt;
iD8DBQE+AIP/OyltUcwYWjsRAtn/AKCGXvYuZSctAt3QO5J7wB3Q6JuurgCfQbVY
GzBH3EIGpqa6jdthYt6o9KY=
=RJZq
-----END PGP SIGNATURE-----

I can't think of any reason why it should take a minute to construct a
tree containing 20,000 nodes. The XSLT 2.0 spec is 21,090 nodes
(elements and text nodes) and builds in 1400ms, including the cost of
parsing the XML.
There's something funny going on here. How long does it take to navigate
your graph if you don't build the tree?
Perhaps it's throwing exceptions and you're ignoring them? Just an idea.
Or perhaps there's something odd about the distribution of node names?
Mike
> -----Original Message-----
> From: saxon-help-admin@...
> [mailto:saxon-help-admin@...] On Behalf Of
> Norman Walsh
> Sent: 18 December 2002 14:20
> To: saxon-help@...
> Subject: [saxon] Fastest way to build a tree?
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Mike,
>
> I have a graph in memory and I want to build the a BFS tree
> view of it for XSLT.
>
> So I construct the BFS tree (on the order of twenty-thousand
> nodes, I'd guess, but it gets built in the blink of an eye).
>
> Then I walk the tree throwing events at an emitter (a simple
> emitter that builds an RTF that I'm eventually going to
> grab). This step seems to be very slow. It takes more than a
> minute to build the tree.
>
> Is there some faster way? I'm tempted to make my own
> extensions of the NodeInfo classes that support tree
> construction so I can just build the graph in the first pass.
> But I wonder if there's a simpler answer that I'm overlooking?
>
> Be seeing you,
> norm
>
> - --
> Norman Walsh <ndw@...> | A man should have any number of little
> http://nwalsh.com/ | aims about which he should be
> conscious
> | and for which he should have
> names, but
> | he should have neither name for, nor
> | consciousness concerning, the main aim
> | of his life.--Samuel Butler
> (II) -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: Processed by Mailcrypt 3.5.7
> <http://mailcrypt.sourceforge.net/&gt;
>
>
> iD8DBQE+AIP/OyltUcwYWjsRAtn/AKCGXvYuZSctAt3QO5J7wB3Q6JuurgCfQbVY
> GzBH3EIGpqa6jdthYt6o9KY=
> =RJZq
> -----END PGP SIGNATURE-----
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:
> With Great Power, Comes Great Responsibility
> Learn to use your power at OSDN's High Performance Computing
> Channel http://hpc.devchannel.org/
> _______________________________________________
> saxon-help mailing list
> saxon-help@...
> https://lists.sourceforge.net/lists/listinfo/s&gt; axon-help
>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[ For the public record ]
/ Norman Walsh <saxon@...> was heard to say:
| / "Michael Kay" <michael.h.kay@...> was heard to say:
| | There's something funny going on here. How long does it take to navigate
| | your graph if you don't build the tree?
|
| I added a little timing code. Walking the graph to build the tree
| takes 172ms; walking the tree and doing nothing else takes 8ms;
| walking the tree again, calling the emitter takes 92881ms.
/ After a couple of private exchanges, Mike said:
>
>Right, I can begin to see what's going on. I had quite forgotten the way
>this worked in the 6.5 branch. The code for result tree fragments is trying
>desperately hard to delay building a tree, which it does by instead holding
>a list of Emitter events, which are then replayed if the RTF is copied, or
>otherwise used as a tree, but not if the RTF is simply used as a string.
>This was more efficient than the fully linked "one object per node" tree
>implementation, but it turns out that it takes a lot more space (and
>therefore time) than the "tinytree", so in 7.x I build a tinytree directly.
>[But I never knew it was quite as bad as this for large trees!]
>
>I think the answer for you is to forget the FragmentValue approach, which is
>fairly bizarre and special purpose, and feed your emitter events directly
>into a com.icl.saxon.tinytree.TinyBuilder - which is also an Emitter. When
>the document has been fully built, you can access the document node using
>getCurrentDocument().
Perfect. Using that approach, 92881ms is reduced to 1293ms. Much more
practical :-)
Thank you, Mike!
Be seeing you,
norm
- --
Norman Walsh <ndw@...> | Sometimes in life situations develop
http://nwalsh.com/ | that only the half-crazy can get out
| of.--La Rochefoucauld
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.7 <http://mailcrypt.sourceforge.net/&gt;
iD8DBQE+AhQwOyltUcwYWjsRAouQAJ4iMOckU5m181NmXAE3hBm9f5uQnwCfdp81
5jCNaxGU3s9sqFwzRZxTMUY=
=GRBC
-----END PGP SIGNATURE-----