Bug 80908 - avoid allocating OOXMLValues when we don't need to ...
Summary: avoid allocating OOXMLValues when we don't need to ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.3.0.0.beta1
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:4.4.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2014-07-04 10:26 UTC by Michael Meeks
Modified: 2015-12-15 23:57 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2014-07-04 10:26:49 UTC
We spend quite a lot of time on import allocating and quickly freeing again XML properties; eg.

class OOXMLBooleanValue : public OOXMLValue
{
protected:
    bool mbValue;

which can only really hold two states.

Instead we should have a pair of these values and simply return either a shared pointer to them or (better) as/when bug#80907 is fixed - have 2x static versions on the stack with an initial ref count set such that they are never destroyed [ in the meantime I guess a static boost::shared_ptr and a static boost::shared_ptr< > Create(bool bBool); type API might make some sense.

Then of course there is the:

class OOXMLIntegerValue : public OOXMLValue
{
protected:
    sal_Int32 mnValue;

I strongly suspect that integer values such as '0' and '1' are some large proportion of these guys; and also our string -> integer conversion is not ultra-fast for single digits; so I would attack:

                case RT_Integer:
                    {
                        sal_Int32 nValue;
                        pAttribs->getAsInteger(nToken,nValue);
                        OOXMLValue::Pointer_t xValue(new OOXMLIntegerValue(nValue));

This code, and instead get the NULL terminated string from pAttribs (cf. the context there) - and pass it to a Create method.

That method could then easily special case single character integers returning a reference to a static array of 10x of them - accelerating the common case, avoiding allocation, and falling back to the slower string->int conversion.

Just some thoughts there;

Thanks !
Comment 1 Commit Notification 2014-07-26 17:51:15 UTC
Jeff Stedfast committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b3d434a9701daab054981c891c645eefe1685b51

fdo#80908 - avoid lots of alloc/free of 2x boolean values.



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 2 Commit Notification 2014-07-26 20:13:02 UTC
Jeffrey Stedfast committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=84aa4d1ff29004b0aa28068b7beb21f7ebfdb239

fdo#80908 - avoid lots of alloc/free of common integer values.



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 3 Jeffrey Stedfast 2014-07-26 21:35:47 UTC
Woot! This is soptimized now!
Comment 4 Robinson Tryon (qubit) 2015-12-15 23:57:27 UTC
Migrating Whiteboard tags to Keywords: (EasyHack DifficultyBeginner SkillCpp TopicCleanup)
[NinjaEdit]