Hello Alvaro,
It's caused by the condition
<xsl:when test="function-available('suwl:unwrapLinks')">...
in the simple.xlink template
(docbook/stylesheet/docbook-xsl/xhtml/inline.xsl). (This test executed
for each xlink (~ 90000 times)).
Yes, it's inefficient but it doesn't affect build time (for me).
You can try to apply the attached patch and measure the time with it.
So If the performance is rather acceptable now I'd continue switch to
XML, and get back to the performance issues after the switch.
(epub generation is much more slow, and I have developed a patch to
speed up it too.)
Best regards,
Alexander
01.12.2016 19:49, Alvaro Herrera wrote:
Pavel Stehule wrote:
It does much more intensive work with IO - I have feeling like there are
intensive fsync.
You could prove that, by running "make html" under "strace -f -e
trace=fsync" etc. I just tried that, and I don't see any fsync. I
guess you could try other syscalls, or simply "-e trace=file". Doing
the latter I noticed an absolutely stupid number of attempts to open
file
/usr/lib/libxslt-plugins/nwalsh_com_xslt_ext_com_nwalsh_saxon_UnwrapLinks.so
which deserves a WTF.
diff --git a/doc/src/sgml/stylesheet-speedup-xhtml.xsl b/doc/src/sgml/stylesheet-speedup-xhtml.xsl
index ff08bef..60c9fd4 100644
--- a/doc/src/sgml/stylesheet-speedup-xhtml.xsl
+++ b/doc/src/sgml/stylesheet-speedup-xhtml.xsl
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/1999/xhtml"
version='1.0'>
@@ -292,4 +293,189 @@
</head>
</xsl:template>
+
+<!-- from /usr/share/xml/docbook/stylesheet/docbook-xsl/xhtml/inline.xsl -->
+<xsl:template name="simple.xlink">
+ <xsl:param name="node" select="."/>
+ <xsl:param name="content">
+ <xsl:apply-templates/>
+ </xsl:param>
+ <xsl:param name="linkend" select="$node/@linkend"/>
+ <xsl:param name="xhref" select="$node/@xlink:href"/>
+
+ <!-- Support for @xlink:show -->
+ <xsl:variable name="target.show">
+ <xsl:choose>
+ <xsl:when test="$node/@xlink:show = 'new'">_blank</xsl:when>
+ <xsl:when test="$node/@xlink:show = 'replace'">_top</xsl:when>
+ <xsl:otherwise/>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="link">
+ <xsl:choose>
+ <xsl:when test="$xhref and (not($node/@xlink:type) or $node/@xlink:type='simple')">
+
+ <!-- Is it a local idref or a uri? -->
+ <xsl:variable name="is.idref">
+ <xsl:choose>
+ <!-- if the href starts with # and does not contain an "(" -->
+ <!-- or if the href starts with #xpointer(id(, it's just an ID -->
+ <xsl:when test="starts-with($xhref,'#') and (not(contains($xhref,'(')) or starts-with($xhref, '#xpointer(id('))">1</xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- Is it an olink ? -->
+ <xsl:variable name="is.olink">
+ <xsl:choose>
+ <!-- If xlink:role="http://docbook.org/xlink/role/olink" -->
+ <!-- and if the href contains # -->
+ <xsl:when test="contains($xhref,'#') and @xlink:role = $xolink.role">1</xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$is.olink = 1">
+ <xsl:call-template name="olink">
+ <xsl:with-param name="content" select="$content"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="$is.idref = 1">
+
+ <xsl:variable name="idref">
+ <xsl:call-template name="xpointer.idref">
+ <xsl:with-param name="xpointer" select="$xhref"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="targets" select="key('id',$idref)"/>
+ <xsl:variable name="target" select="$targets[1]"/>
+
+ <xsl:call-template name="check.id.unique">
+ <xsl:with-param name="linkend" select="$idref"/>
+ </xsl:call-template>
+
+ <xsl:choose>
+ <xsl:when test="count($target) = 0">
+ <xsl:message>
+ <xsl:text>XLink to nonexistent id: </xsl:text>
+ <xsl:value-of select="$idref"/>
+ </xsl:message>
+ <xsl:copy-of select="$content"/>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <a>
+ <xsl:apply-templates select="." mode="common.html.attributes"/>
+ <xsl:call-template name="id.attribute"/>
+
+ <xsl:attribute name="href">
+ <xsl:call-template name="href.target">
+ <xsl:with-param name="object" select="$target"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:choose>
+ <xsl:when test="$node/@xlink:title">
+ <xsl:attribute name="title">
+ <xsl:value-of select="$node/@xlink:title"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$target" mode="html.title.attribute"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:if test="$target.show !=''">
+ <xsl:attribute name="target">
+ <xsl:value-of select="$target.show"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:copy-of select="$content"/>
+
+ </a>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <!-- otherwise it's a URI -->
+ <xsl:otherwise>
+ <a>
+ <xsl:apply-templates select="." mode="common.html.attributes"/>
+ <xsl:call-template name="id.attribute"/>
+ <xsl:attribute name="href">
+ <xsl:value-of select="$xhref"/>
+ </xsl:attribute>
+ <xsl:if test="$node/@xlink:title">
+ <xsl:attribute name="title">
+ <xsl:value-of select="$node/@xlink:title"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <!-- For URIs, use @xlink:show if defined, otherwise use ulink.target -->
+ <xsl:choose>
+ <xsl:when test="$target.show !=''">
+ <xsl:attribute name="target">
+ <xsl:value-of select="$target.show"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="$ulink.target !=''">
+ <xsl:attribute name="target">
+ <xsl:value-of select="$ulink.target"/>
+ </xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:copy-of select="$content"/>
+ </a>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:when test="$linkend">
+ <xsl:variable name="targets" select="key('id',$linkend)"/>
+ <xsl:variable name="target" select="$targets[1]"/>
+
+ <xsl:call-template name="check.id.unique">
+ <xsl:with-param name="linkend" select="$linkend"/>
+ </xsl:call-template>
+
+ <a>
+ <xsl:apply-templates select="." mode="common.html.attributes"/>
+ <xsl:call-template name="id.attribute"/>
+ <xsl:attribute name="href">
+ <xsl:call-template name="href.target">
+ <xsl:with-param name="object" select="$target"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:apply-templates select="$target" mode="html.title.attribute"/>
+
+ <xsl:copy-of select="$content"/>
+
+ </a>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$content"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+<!-- in attempt to speed up `make html`
+ <xsl:choose>
+ <xsl:when test="function-available('suwl:unwrapLinks')">
+ <xsl:copy-of select="suwl:unwrapLinks($link)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$link"/>
+ </xsl:otherwise>
+ </xsl:choose>
+-->
+ <xsl:copy-of select="$link"/>
+</xsl:template>
+
</xsl:stylesheet>
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers