doc: Speed up XSLT builds
authorPeter Eisentraut
Thu, 18 Aug 2016 16:00:00 +0000 (12:00 -0400)
committerPeter Eisentraut
Thu, 18 Aug 2016 16:00:00 +0000 (12:00 -0400)
The upstream XSLT stylesheets use some very general XPath expressions in
some places that end up being very slow.  We can optimize them with
knowledge about the DocBook document structure and our particular use
thereof.  For example, when counting preceding chapters to get a number
for the current chapter, we only need to count preceding sibling
nodes (more or less) instead of searching through the entire node tree
for chapter elements.

This change attacks the slowest pieces as identified by xsltproc
--profile.  This makes the HTML build roughly 10 times faster, resulting
in the new total build time being about the same as the old DSSSL-based
build.  Some of the non-HTML build targets (especially FO) will also
benefit a bit, but they have not been specifically analyzed.

With this, also remove the pg.fast parameter, which was previously a
hack to get the build to a manageable speed.

Alexander Lakhin , with some additional
tweaking by me

doc/src/sgml/stylesheet-common.xsl
doc/src/sgml/stylesheet-speedup-common.xsl [new file with mode: 0644]
doc/src/sgml/stylesheet-speedup-xhtml.xsl [new file with mode: 0644]
doc/src/sgml/stylesheet.xsl

index de3637624afeee26fee35b1acd7bb96d3211055f..e3841130eb75482cc7205c69f051c303b00b55f9 100644 (file)
@@ -7,11 +7,10 @@
   all output formats (HTML, HTML Help, XSL-FO, etc.).
   -->
 
+
 
 
 
-
-
 
+
+
+
+
+  
+    
+      
+    
+    
+      
+                      ancestor::part">
+        
+          
+                               mode="label.markup"/>
+        
+        
+          
+          
+                               mode="intralabel.punctuation">
+            
+          
+        
+      
+      
+        
+          
+        
+      
+      
+        
+          
+        
+        
+          
+          
+          
+        
+      
+    
+  
+
+
+
+  
+    
+      
+    
+    
+      
+                      ancestor::part">
+        
+          
+                               mode="label.markup"/>
+        
+        
+          
+          
+                               mode="intralabel.punctuation">
+            
+          
+        
+      
+      
+        
+          
+        
+      
+      
+        
+          
+        
+        
+          
+          
+          
+        
+      
+    
+  
+
+
+
diff --git a/doc/src/sgml/stylesheet-speedup-xhtml.xsl b/doc/src/sgml/stylesheet-speedup-xhtml.xsl
new file mode 100644 (file)
index 0000000..8428dc5
--- /dev/null
@@ -0,0 +1,252 @@
+
+
+                xmlns="http://www.w3.org/1999/xhtml"
+                version='1.0'>
+
+
+
+
+
+
+  
+  
+  
+  
+  
+
+  
+    
+      
+    
+  
+
+  
+    
+      
+    
+  
+
+  
+    
+      
+    
+  
+
+  
+    
+      
+    
+    
+      
+    
+    
+      
+    
+  
+
+  
+    
+      
+        
+        
+        
+        
+        
+      
+    
+    
+      
+        
+        
+          
+            
+              
+            
+            
+              
+            
+          
+        
+
+        
+          
+            
+              
+                
+                
+                
+                
+              
+            
+            
+              
+                
+                
+              
+            
+          
+
+        
+
+         
+
+      
+      
+        
+          
+          
+          
+          
+          
+        
+      
+    
+  
+
+
+
+  
+  
+  
+  
+
+  
+    
+      
+      
+
+      
+        
+        
+        
+          
+            
+            
+          
+        
+        
+      
+      
+        
+        
+        
+        
+        
+      
+    
+    
+      
+      
+
+      
+        
+        
+        
+          
+            
+            
+            
+            
+          
+        
+        
+    
+  
+
+
+
+
+
+
+  
+    
+  
+
+  
+
+  
+    
+      Error: If you change $chunk.section.depth, then you must update the performance-optimized chunk-all-sections-template.
+    
+  
+
+  
+    select="(preceding::book[1]
+             |preceding::preface[1]
+             |preceding::chapter[1]
+             |preceding::appendix[1]
+             |preceding::part[1]
+             |preceding::reference[1]
+             |preceding::refentry[1]
+             |preceding::colophon[1]
+             |preceding::article[1]
+             |preceding::topic[1]
+             |preceding::bibliography[parent::article or parent::book or parent::part][1]
+             |preceding::glossary[parent::article or parent::book or parent::part][1]
+             |preceding::index[$generate.index != 0]
+                               [parent::article or parent::book or parent::part][1]
+             |preceding::setindex[$generate.index != 0][1]
+             |ancestor::set
+             |ancestor::book[1]
+             |ancestor::preface[1]
+             |ancestor::chapter[1]
+             |ancestor::appendix[1]
+             |ancestor::part[1]
+             |ancestor::reference[1]
+             |ancestor::article[1]
+             |ancestor::topic[1]
+             |preceding::sect1[1]
+             |ancestor::sect1[1])[last()]"/>
+
+  
+    select="(following::book[1]
+             |following::preface[1]
+             |following::chapter[1]
+             |following::appendix[1]
+             |following::part[1]
+             |following::reference[1]
+             |following::refentry[1]
+             |following::colophon[1]
+             |following::bibliography[parent::article or parent::book or parent::part][1]
+             |following::glossary[parent::article or parent::book or parent::part][1]
+             |following::index[$generate.index != 0]
+                               [parent::article or parent::book][1]
+             |following::article[1]
+             |following::topic[1]
+             |following::setindex[$generate.index != 0][1]
+             |descendant::book[1]
+             |descendant::preface[1]
+             |descendant::chapter[1]
+             |descendant::appendix[1]
+             |descendant::article[1]
+             |descendant::topic[1]
+             |descendant::bibliography[parent::article or parent::book][1]
+             |descendant::glossary[parent::article or parent::book or parent::part][1]
+             |descendant::index[$generate.index != 0]
+                                [parent::article or parent::book][1]
+             |descendant::colophon[1]
+             |descendant::setindex[$generate.index != 0][1]
+             |descendant::part[1]
+             |descendant::reference[1]
+             |descendant::refentry[1]
+             |following::sect1[1]
+             |descendant::sect1[1])[1]"/>
+
+  
+    
+    
+    
+  
+
+
+
index 7967b361dd8b0498911904f09fa8ef8a8fa86344..631fcc4edfcbb5e3c6261a4a8caba42bafb89b93 100644 (file)
@@ -6,6 +6,7 @@
 
 
 
+