Kaydet (Commit) d6bd9c27 authored tarafından Noel Grandin's avatar Noel Grandin

tdf#79878 perf loading docx file, disable SAX threading for writer

since it seems to cost us 20% performance

Change-Id: Ic4796ee3756c8c722feb4851dc48a99e882ba0fe
Reviewed-on: https://gerrit.libreoffice.org/57545Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d375324a
......@@ -247,6 +247,7 @@ public:
void parse();
void produce( bool bForceFlush = false );
bool m_bIgnoreMissingNSDecl;
bool m_bDisableThreadedParser;
private:
bool consume(EventList&);
......@@ -634,6 +635,7 @@ namespace sax_fastparser {
FastSaxParserImpl::FastSaxParserImpl() :
m_bIgnoreMissingNSDecl(false),
m_bDisableThreadedParser(false),
mpTop(nullptr)
{
mxDocumentLocator.set( new FastLocatorImpl( this ) );
......@@ -781,7 +783,7 @@ void FastSaxParserImpl::parseStream(const InputSource& rStructSource)
rEntity.mxDocumentHandler->startDocument();
}
if (!getenv("SAX_DISABLE_THREADS"))
if (!getenv("SAX_DISABLE_THREADS") && !m_bDisableThreadedParser)
{
Reference<css::io::XSeekable> xSeekable(rEntity.maStructSource.aInputStream, UNO_QUERY);
// available() is not __really__ relevant here, but leave it in as a heuristic for non-seekable streams
......@@ -1325,11 +1327,16 @@ FastSaxParser::initialize(css::uno::Sequence< css::uno::Any > const& rArguments)
if (rArguments.getLength())
{
OUString str;
if ( ( rArguments[0] >>= str ) && "IgnoreMissingNSDecl" == str )
if ( rArguments[0] >>= str )
{
if ( str == "IgnoreMissingNSDecl" )
mpImpl->m_bIgnoreMissingNSDecl = true;
else if ( str == "DoSmeplease" )
{
//just ignore as this is already immune to billion laughs
; //just ignore as this is already immune to billion laughs
else if ( str == "DisableThreadedParser" )
mpImpl->m_bDisableThreadedParser = true;
else
throw IllegalArgumentException();
}
else
throw IllegalArgumentException();
......
......@@ -152,6 +152,11 @@ def getFastParser():
if (!mxFastParser.is())
{
mxFastParser = css::xml::sax::FastParser::create(mxContext);
// the threaded parser is about 20% slower loading writer documents
css::uno::Reference< css::lang::XInitialization > xInit( mxFastParser, css::uno::UNO_QUERY_THROW );
css::uno::Sequence< css::uno::Any > args(1);
args[0] <<= OUString("DisableThreadedParser");
xInit->initialize(args);
""")
for url in sorted(ooxUrlAliases.keys()):
print(""" mxFastParser->registerNamespace("%s", oox::NMSP_%s);""" % (url, ooxUrlAliases[url]))
......@@ -167,6 +172,7 @@ def getFastParser():
def createImpl(model):
print("""
#include <com/sun/star/xml/sax/FastParser.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include "ooxml/OOXMLFactory.hxx"
#include "ooxml/OOXMLFastHelper.hxx"
#include "ooxml/OOXMLStreamImpl.hxx"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment