Re: [xslt] speeding up xslt in gtk-doc



On 08.05.2011 11:44, Daniel Veillard wrote:
> On Fri, May 06, 2011 at 05:49:20PM +0300, Stefan Kost wrote:
>> On 04.05.2011 12:18, Daniel Veillard wrote:
>>> On Wed, May 04, 2011 at 11:43:03AM +0300, Stefan Kost wrote:
>>>> On 03.05.2011 18:14, Stefan Kost wrote:
>>>>> hi,
>>>>>
>>>>> I am still not happy with the time it takes for gtk-doc to generate the
>>>>> html. I did some profiling and tired various changes. Its not too
>>>>> impressive. Just posting them here for feedback and comment on the
>>>>> directions of what would be acceptable or not. I technically have commit
>>>>> rights, so I can push things once they are ready. If patch 0002 looks
>>>>> like a good idea, I can extend it for other accessors.
>>>> Daniel, btw. are you fine with me pushing a couple of obvious patches
>>>> that only fix compiler warnings (like unused variables and missing
>>>> casts). I would do that for libxml2 and libxslt.
>> There are a lot of warnings like this:
>> ISO C90 does not support "long long"
>   Ignore all compilers where we need this have it
I'll investigate if we could easily add "CFLAGS=-Wno-/long/-/long/".

>> ISO C forbids assignment between function pointer and 'void *'
>   Leave them, they come from an API definition, we can't really change
> it as it's public, and trying to hide the issue isn't good either,
> we need to learn to live with those.
okay.
>> not sure how you want to handle them.
>>
>> Also tests have a few
>> ignoring return value of 'write', declared with attribute warn_unused_result
>> that could be taken care of if desired.
>   that would be a good idea, yes
0002-various-handle-return-values-of-write-calls.patch

This should not fail in most cases and thus just doing (void)write(....)
could be used as well.
>> For
>> 0006-xmlmemory-add-a-cast-size_t-has-no-portable-printf-m.patch
>> I would actually suggest to use "%lu" and (long unsigned) when using
>> that with a size_t.
> [...]
>> diff --git a/xpath.c b/xpath.c
>> index a857590..d4db467 100644
>> --- a/xpath.c
>> +++ b/xpath.c
>> @@ -7669,7 +7669,7 @@ xmlXPathNextDescendantOrSelfElemParent(xmlNodePtr cur,
>>  #ifdef LIBXML_DOCB_ENABLED
>>  	    case XML_DOCB_DOCUMENT_NODE:
>>  #endif
>> -	    case XML_HTML_DOCUMENT_NODE:	    
>> +	    case XML_HTML_DOCUMENT_NODE:
>>  		return(contextNode);
>>  	    default:
>>  		return(NULL);
>> @@ -12420,7 +12420,7 @@ apply_predicates: /* --------------------------------------------------- */
>>          if ((predOp != NULL) && (seq->nodeNr > 0)) {
>>  	    /*
>>  	    * E.g. when we have a "/foo[some expression][n]".
>> -	    */	    
>> +	    */
>>  	    /*
>>  	    * QUESTION TODO: The old predicate evaluation took into
>>  	    *  account location-sets.
>> @@ -12429,7 +12429,7 @@ apply_predicates: /* --------------------------------------------------- */
>>  	    *  All what I learned now from the evaluation semantics
>>  	    *  does not indicate that a location-set will be processed
>>  	    *  here, so this looks OK.
>> -	    */	    
>> +	    */
>>  	    /*
>>  	    * Iterate over all predicates, starting with the outermost
>>  	    * predicate.
> that's just end of line blanks, the problem is that they are all over
> the place. Fixing only 3 of them doesn't really solve the issue, and
> fixing all of them introduce a lot of churn making potential
> backporting harder on new patches.
> So far I resisted cleaning them up for this reason.
I am just collecting all those in one huge patch for now.
>> >From 20da44a0d8c1cfbf963cde3825fbc66b513e0ddd Mon Sep 17 00:00:00 2001
>> From: Stefan Kost <ensonic users sf net>
>> Date: Fri, 6 May 2011 17:03:51 +0300
>> Subject: [PATCH 5/6] xpath: remove unused variable
>>
>> As noted by gcc, this variable is not beeing used.
>> ---
>>  xpath.c |    1 -
>>  1 files changed, 0 insertions(+), 1 deletions(-)
>>
>> diff --git a/xpath.c b/xpath.c
>> index 0bb6f43..5258b3a 100644
>> --- a/xpath.c
>> +++ b/xpath.c
>> @@ -10030,7 +10030,6 @@ static void
>>  xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
>>  {
>>      double ret = 0.0;
>> -    double mult = 1;
>>      int ok = 0;
>>      int exponent = 0;
>>      int is_exponent_negative = 0;
>> -- 
>> 1.7.1
>   Ok, ACK
pushed.
>> >From f3bf078327f038f3de29ca36897b3768ab340062 Mon Sep 17 00:00:00 2001
>> From: Stefan Kost <ensonic users sf net>
>> Date: Fri, 6 May 2011 17:40:10 +0300
>> Subject: [PATCH 6/6] xmlmemory: add a cast size_t has no portable printf modifier
>>
>> ---
>>  xmlmemory.c |    9 ++++++---
>>  1 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/xmlmemory.c b/xmlmemory.c
>> index 433abb8..984aa82 100644
>> --- a/xmlmemory.c
>> +++ b/xmlmemory.c
>> @@ -205,7 +205,8 @@ xmlMallocLoc(size_t size, const char * file, int line)
>>  
>>      if (xmlMemTraceBlockAt == ret) {
>>  	xmlGenericError(xmlGenericErrorContext,
>> -			"%p : Malloc(%ld) Ok\n", xmlMemTraceBlockAt, size);
>> +			"%p : Malloc(%ld) Ok\n", xmlMemTraceBlockAt,
>> +			(long int)size);
>>  	xmlMallocBreakpoint();
>>      }
>>  
>> @@ -273,7 +274,8 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
>>  
>>      if (xmlMemTraceBlockAt == ret) {
>>  	xmlGenericError(xmlGenericErrorContext,
>> -			"%p : Malloc(%ld) Ok\n", xmlMemTraceBlockAt, size);
>> +			"%p : Malloc(%ld) Ok\n", xmlMemTraceBlockAt,
>> +			(long int)size);
>>  	xmlMallocBreakpoint();
>>      }
>>  
>> @@ -349,7 +351,8 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
>>      if (xmlMemTraceBlockAt == ptr) {
>>  	xmlGenericError(xmlGenericErrorContext,
>>  			"%p : Realloced(%ld -> %ld) Ok\n",
>> -			xmlMemTraceBlockAt, p->mh_size, size);
>> +			xmlMemTraceBlockAt, (long int)p->mh_size,
>> +			(long int)size);
>>  	xmlMallocBreakpoint();
>>      }
>>      p->mh_tag = MEMTAG;
>   agreed %lu and (unsigned long) cast would be better.
push with the above changes.
> Daniel
>
>

>From 165c923fb09095f5f8d242fa9098a0e88d7dc8e6 Mon Sep 17 00:00:00 2001
From: Stefan Kost <ensonic users sf net>
Date: Mon, 9 May 2011 12:14:59 +0300
Subject: [PATCH 2/9] various: handle return values of write calls

---
 nanohttp.c |   18 ++++++++++++------
 testC14N.c |    6 ++++--
 xmllint.c  |   16 ++++++++++++----
 3 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/nanohttp.c b/nanohttp.c
index f669457..a8af0e1 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -1615,7 +1615,8 @@ xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) {
     char *buf = NULL;
     int fd;
     int len;
-    
+    int ret = 0;
+
     if (filename == NULL) return(-1);
     ctxt = xmlNanoHTTPOpen(URL, contentType);
     if (ctxt == NULL) return(-1);
@@ -1636,12 +1637,14 @@ xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) {
 
     xmlNanoHTTPFetchContent( ctxt, &buf, &len );
     if ( len > 0 ) {
-	write(fd, buf, len);
+	if (write(fd, buf, len) == -1) {
+	    ret = -1;
+	}
     }
 
     xmlNanoHTTPClose(ctxt);
     close(fd);
-    return(0);
+    return(ret);
 }
 
 #ifdef LIBXML_OUTPUT_ENABLED
@@ -1660,7 +1663,8 @@ xmlNanoHTTPSave(void *ctxt, const char *filename) {
     char *buf = NULL;
     int fd;
     int len;
-    
+    int ret = 0;
+
     if ((ctxt == NULL) || (filename == NULL)) return(-1);
 
     if (!strcmp(filename, "-")) 
@@ -1675,12 +1679,14 @@ xmlNanoHTTPSave(void *ctxt, const char *filename) {
 
     xmlNanoHTTPFetchContent( ctxt, &buf, &len );
     if ( len > 0 ) {
-	write(fd, buf, len);
+	if (write(fd, buf, len) == -1) {
+	    ret = -1;
+	}
     }
 
     xmlNanoHTTPClose(ctxt);
     close(fd);
-    return(0);
+    return(ret);
 }
 #endif /* LIBXML_OUTPUT_ENABLED */
 
diff --git a/testC14N.c b/testC14N.c
index fbfa869..dc1a9a6 100644
--- a/testC14N.c
+++ b/testC14N.c
@@ -104,8 +104,10 @@ test_c14n(const char* xml_filename, int with_comments, int mode,
 	    with_comments, &result);
     if(ret >= 0) {
 	if(result != NULL) {
-	    write(1, result, ret);
-	    xmlFree(result);          
+	    if (write(STDOUT_FILENO, result, ret) == -1) {
+		fprintf(stderr, "Can't write data\n");
+	    }
+	    xmlFree(result);
 	}
     } else {
 	fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret);
diff --git a/xmllint.c b/xmllint.c
index b7af32f..8af56cd 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -2550,7 +2550,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 
 		size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result);
 		if (size >= 0) {
-		    write(1, result, size);
+		    if (write(1, result, size) == -1) {
+		        fprintf(stderr, "Can't write data\n");
+		    }
 		    xmlFree(result);
 		} else {
 		    fprintf(stderr, "Failed to canonicalize\n");
@@ -2562,7 +2564,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 
 		size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result);
 		if (size >= 0) {
-		    write(1, result, size);
+		    if (write(1, result, size) == -1) {
+		        fprintf(stderr, "Can't write data\n");
+		    }
 		    xmlFree(result);
 		} else {
 		    fprintf(stderr, "Failed to canonicalize\n");
@@ -2575,7 +2579,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 
 		size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result);
 		if (size >= 0) {
-		    write(1, result, size);
+		    if (write(1, result, size) == -1) {
+		        fprintf(stderr, "Can't write data\n");
+		    }
 		    xmlFree(result);
 		} else {
 		    fprintf(stderr, "Failed to canonicalize\n");
@@ -2604,7 +2610,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
 		    fprintf(stderr, "Failed to save\n");
 		    progresult = XMLLINT_ERR_OUT;
 		} else {
-		    write(1, result, len);
+		    if (write(1, result, len) == -1) {
+		        fprintf(stderr, "Can't write data\n");
+		    }
 		    xmlFree(result);
 		}
 
-- 
1.7.1



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