From: Johnny Lee (typo_pl@hotmail.com)
Date: Wed Oct 01 2003 - 07:17:14 EDT
Nice find. Your patch knocked import time from ~22 seconds to ~15 seconds on 
my box.
I've got 2 patches which drop import time by another ~4 seconds altogether.
Import time for the RTF spec is ~11 seconds now, followed by many seconds 
doing "Building document...".
First patch, bug5291a.txt, knocks ~2 seconds from the import time.
Changes:
- Building upon Robert's changes, I changed the code from doing a linear 
search to do a binary search in UT_Vector::addItemSorted. The binary search 
will return the spot where the new item should be inserted.
- The original linear search had a bug which would not insert an item after 
the only item in the vector (the vector always has a default empty AP with 
checlsum 0).
- Made a common private method for doing binary searches in UT_Vector since 
the binarySearch method uses almost the same code.
- Changed the createAP methods in pp_TableAttrProp from sorting the vector 
after each add to using the addItemSorted method. Ditched the sortTable 
method since code doesn't use it anymore.
Second patch, bug5291b.txt, comes from looking at the profile output. I 
noticed the following:
Module Statistics for abiword.exe
---------------------------------
    Time in module: 15302.935 millisecond
    Percent of time in module: 100.0%
    Functions in module: 11530
    Hits in module: 39325065
    Module function coverage: 7.1%
        Func          Func+Child           Hit
        Time   %         Time      %      Count  Function
---------------------------------------------------------
       0.018   0.0    15302.866 100.0        1 PD_Document::readFromFile
       0.200   0.0    15251.752  99.7        1 IE_Imp_RTF::importFile
       0.011   0.0    15217.363  99.4        4 IE_Imp_RTF::_parseFile
     141.625   0.9    15216.265  99.4      105 IE_Imp_RTF::_parseText
      35.198   0.2    13122.018  85.7    90402 IE_Imp_RTF::ParseRTFKeyword
     105.277   0.7    12748.765  83.3    90403 IE_Imp_RTF::TranslateKeyword
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
       2.502   0.0     5296.926  34.6        1 
IE_Imp_RTF::HandleStyleDefinition
       1.599   0.0     5276.492  34.5      101 PD_Document::appendStyle
       4.997   0.0     5250.106  34.3     8282 pt_PieceTable::enumStyles
     766.147   5.0     4826.000  31.5    11406 UT_Vector::qsort
    1468.353   9.6     4059.150  26.5  5816405 compareStyleNames
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      31.705   0.2     3860.252  25.2    53563 IE_Imp_RTF::FlushStoredChars
compareStyleNames is getting called a lot, along with several other 
style-related functions, including pt_PieceTable::enumStyles.
Tracking down the code revealed the source as 
abi\src\text\ptbl\xp\pt_PT_Styles.cpp:
//
// Diagonostic on Append...
//
                const PD_Style * pdStyle = NULL;
                const char * psdName =NULL;
                UT_uint32 i = 0;
                for(i=0; i<getStyleCount(); i++)
                {
                        enumStyles(i,&psdName,&pdStyle);
                        xxx_UT_DEBUGMSG(("SEVIOR: Found %d style name %s \n",i,psdName));
                }
I wrapped this code in a #ifdef DEBUG and import time dropped by another 2 
seconds.
J
>From: Robert Wilhelm <robert.wilhelm@gmx.net>
>To: AbiWord <abiword-dev@abisource.com>
>Subject: PATCH: Next 5291 speedup
>Date: Tue, 30 Sep 2003 20:42:38 +0200
>
>After Johnny Lees cool checksum and binary search patch, I profiled
>abiword again and we spent lot of time in qsort. See following call
>tree:
>
>percent      num
>cumulative  calls
>28.15	   21952     	 addIfUniqueAP
>27.46       5120	  addAP
>   	 		qsort
>12.80	   72M		compareAP
>4.34	  149M		ppAttrProp:GetCheckSum
>
>As m_vecTableSorted is already sorted I changed addAP to
>just use a linear search and insert the new AP at the right place.
>Now  addIfUniqueAP does no longer show up on the profile radar,
>and the time for importing the RTF spec decreased from 55s to 49s on my
>machine.
>
>Robert
><< AP.patch >>
_________________________________________________________________
Instant message with integrated webcam using MSN Messenger 6.0. Try it now 
FREE!  http://msnmessenger-download.com
This archive was generated by hypermail 2.1.4 : Wed Oct 01 2003 - 07:32:37 EDT