According to the xml:id specification <http://www.w3.org/TR/xml-id/>:

> An xml:id processor should assure that the following constraint holds:
>   * The values of all attributes of type “ID” (which includes all xml:id
>     attributes) within a document are unique.

libxml2 follows this recommendation, which is normally the good thing. However,
ensuring uniqueness of xml:id attributes takes time and memory. For XML
documents with many such attributes (which is often the case for morphosyntax
annotations in the TEI4NKJP format) this feature, which cannot be turned off,
can kill bpng performance.

To work-around the problem, you can use the following patch, which turns of
xml:id uniqueness checks in the XML steaming API.

Please note that that other software may rely on the feature that this patch
disables. Please don't install such a patched version of libxml2 system-wide!

See also the following bug report:
https://bugzilla.gnome.org/show_bug.cgi?id=647312

--- a/xmlreader.c
+++ b/xmlreader.c
@@ -5109,6 +5108,7 @@
         reader->validate = XML_TEXTREADER_VALIDATE_DTD;
 
     xmlCtxtUseOptions(reader->ctxt, options);
+    reader->ctxt->loadsubset |= XML_SKIP_IDS;
     if (encoding != NULL) {
         xmlCharEncodingHandlerPtr hdlr;
 
