Re: XSLT compilation is slow for big XSLTs
Nick Wellnhofer <[email protected]> Thu, 27 Aug 2015 14:32:53 +0200
| Newsgroups | gmane.comp.gnome.lib.xslt |
|---|---|
| Message-ID | <[email protected]> |
On 20/08/2015 19:21, Christian Ceelen wrote: > Ok. I think i found the answer by trial and error myself. I was not able to > look up the named templates in the hash table for the (pre-) compiled templates. > > So i followed Nick's suggest and came up with this first draft: > https://github.com/GNOME/libxslt/pull/1 Some quick comments: - It's nice that you create the hash lazily. - The helper function xsltHasNamedTemplate doesn't seem to be necessary since it's used only once. - xmlHashCreate(1024) creates a hash table with 1024 initial slots. This value should be reduced to something sensible like 4. I think reordering structs in xsltInternals.h doesn't break ABI compatibility. So `namedTemplatesHash` could be moved to the other template fields. But I'm not 100% sure. > I tested locally and didn't get any surprises. I also created a simple test > with 2 named templates that have the same name to test for collision > detection. The new code behaves in that case as the previous one. But so far I > have no idea yet where and how to add it to the tests in the test suite as > this is a test for failure detection. Put your test files in: - tests/REC/test-6-2.xml - tests/REC/test-6-2.xsl Then run `make tests`. This will create files - tests/REC/test-6-2.out - tests/REC/test-6-2.err (if there's stderr output) Inspect the contents of the `.out` and `.err` files. If everything's OK, add them to version control. > Looking at a second glance at the imports.c and xsltFindTemplate i think it > would be worthwhile to add the new function i created for lookup in the hash > table in the file imports.c and try to encapsulate the behavior there. Do you > think i should refactor the code in that direction? I don't think it's necessary to add any helper functions. But please change the lookup code in imports.c to make use of the named templates hash. Nick