Re: [xml] xmllint --postvalid much slower than --valid [PATCH]

On Monday 23 February 2004 11:08, Daniel Veillard wrote:
  Can you bugzilla this ? BTW, only --valid really mean DTD validation in
the sense of the definition in the XML REC. Also I think I did make my
patch when testing with your data when using --dtdvalid (as your files were
not having a DOCTYPE, if I remember correctly --postvalid would not work).

That's true, but I do have DOCTYPE in the production files, so that's not it.  
The same difference appears even with --dtdvalid and --postvalid.

  yes. best is to relink statically for profiling with gprof. Please
double check you're really using the new shared libraries and if problem
persists, then bugzilla.

Thanks for the hint on gprof. That allowed me to identify and fix the problem 
(patch attached). The real problem actually is related to what I reported 
before. xmlAddRef uses xmlHash/xmlList combination to store IDREFs 
attributes. The problem is that both xmlListInsert and xmlListAppend work 
with ordered lists (they search for first lower/higher element in the list 
before inserting/appending). Unless a comparing function is given, the 
default one, xmlListCompare, is used. This function compares data as numbers. 
In our case the data are strucutures, so their pointer addresses are 
compared. So with --valid/--dtdvalid, xmlListAppend seems to be quicker (as 
the pointers grow) while with --postvalid it may/may not be otherwise  
(because almost all memory is already allocated so the pointer values don't 
necessarily grow). But in fact, there is no need for any ordering at all, so 
it is quite sufficient to pass the list constructor a dummy comparison 
function which always returns 0 (elements are equal). Then 
xmlListAppend/xmlListInsert may be used equally  (no real difference).
That's what my patch does. All tests pass with it, so it should be safe to 
apply, but you may want to check the naming and placing of xmlDummyCompare.


Attachment: valid.patch
Description: Text Data

Attachment: pgpPHNphDzyIv.pgp
Description: signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]