Difference between revisions of "ODT saving performance improvement"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 1: Line 1:
 
[[Category:Performance]]
 
[[Category:Performance]]
  
=='''Investigation of ODT saving performance'''==
+
=='''1. Investigation of ODT saving performance'''==
 
We started a profiling of the saving performance on a current AOO build with Quantify on Windows. One document(sw_complex_100p.odt) are profiled for a save procedure.  
 
We started a profiling of the saving performance on a current AOO build with Quantify on Windows. One document(sw_complex_100p.odt) are profiled for a save procedure.  
  
Line 18: Line 18:
 
For  SwGrfNode::SwapIn,  through analyzing data collected from quantify, one phenomenon is that graphic will be first swapped in, after saving, it will be swapped out. If document contains lots of graphics, it will influence saving performance immensely.
 
For  SwGrfNode::SwapIn,  through analyzing data collected from quantify, one phenomenon is that graphic will be first swapped in, after saving, it will be swapped out. If document contains lots of graphics, it will influence saving performance immensely.
  
=='''Solution'''==
+
=='''2. Solution'''==
 
*1.Don't paint thumbnail in saving procedure.
 
*1.Don't paint thumbnail in saving procedure.
 
*2.Don't swap out and swap in graphics so frequently when saving.
 
*2.Don't swap out and swap in graphics so frequently when saving.
  
=='''Graphic Management Mechanism'''==
+
=='''3. Graphic Management Mechanism'''==
 
Give a brief description to solution 2.
 
Give a brief description to solution 2.
  
'''1.Graphic Manager'''
+
'''3.1. Graphic Manager'''
  
 
Graphic Manager is responsible for all graphic objects’ register, unregister, drawing, and graphic’s cache. It is a global variable.  
 
Graphic Manager is responsible for all graphic objects’ register, unregister, drawing, and graphic’s cache. It is a global variable.  
  
'''2.Graphic Cache'''
+
'''3.2. Graphic Cache'''
  
 
For management of Graphic Cache, Graphic Manager supplies a series of interfaces: graphic object cache size settings, swap graphic in, swap graphic out, swap timer, etc.
 
For management of Graphic Cache, Graphic Manager supplies a series of interfaces: graphic object cache size settings, swap graphic in, swap graphic out, swap timer, etc.
Line 41: Line 41:
 
Graphic that before it transforming to bitmap or metafile, namely B. For its memory management, there is only one copy in memory, no matter how many times it is be used. In addition, it will be swapped in memory as temp file only when the graphic is present to user, that is to say, you can see it with your eyes. When move to next page, it will be swapped out to disk again.
 
Graphic that before it transforming to bitmap or metafile, namely B. For its memory management, there is only one copy in memory, no matter how many times it is be used. In addition, it will be swapped in memory as temp file only when the graphic is present to user, that is to say, you can see it with your eyes. When move to next page, it will be swapped out to disk again.
  
'''3.Optimization of graphic cache'''
+
'''3.3. Optimization of graphic cache'''
  
 
Sample file: document that contains lots of graphic (bmp, jpg, wmf) in it.
 
Sample file: document that contains lots of graphic (bmp, jpg, wmf) in it.
 +
 
Root cause: Graphic will be swapped in memory as temp file only when the graphic is present to user, that is to say, you can see it with your eyes. When move to next page, it will be swapped out to disk again.
 
Root cause: Graphic will be swapped in memory as temp file only when the graphic is present to user, that is to say, you can see it with your eyes. When move to next page, it will be swapped out to disk again.
 +
 
Solution: Do limit on memory B’s size. In order to avoid frequently swapping in/out, do limit on B like A, a max memory  M will set to B. If exceeding M,  the swap out and vice versa. This method can improve saving performance by 20%.
 
Solution: Do limit on memory B’s size. In order to avoid frequently swapping in/out, do limit on B like A, a max memory  M will set to B. If exceeding M,  the swap out and vice versa. This method can improve saving performance by 20%.

Revision as of 09:30, 12 June 2012


1. Investigation of ODT saving performance

We started a profiling of the saving performance on a current AOO build with Quantify on Windows. One document(sw_complex_100p.odt) are profiled for a save procedure.

The analysis of the data should be:

  • 1.show, if the profiler output is stable and reproducible
  • 2.identify the hotspots of the current implementation
  • 3.be a basis to evaluate the progress by optimization


For benchmark document: sw_complex_100p.odt, it is consisted of many graphics. Following shows the hotspots(marked in blue) in saving procedure.

From these data, we can know, SfxObjectShell::GenerateAndStoreThumbnail and SwGrfNode::SwapIn occupy too much time than expected.

For SfxObjectShell::GenerateAndStoreThumbnail, we found it will call SwFlyFrm::Paint several times, but it's unnecessary to paint thumbnail when saving.

For SwGrfNode::SwapIn, through analyzing data collected from quantify, one phenomenon is that graphic will be first swapped in, after saving, it will be swapped out. If document contains lots of graphics, it will influence saving performance immensely.

2. Solution

  • 1.Don't paint thumbnail in saving procedure.
  • 2.Don't swap out and swap in graphics so frequently when saving.

3. Graphic Management Mechanism

Give a brief description to solution 2.

3.1. Graphic Manager

Graphic Manager is responsible for all graphic objects’ register, unregister, drawing, and graphic’s cache. It is a global variable.

3.2. Graphic Cache

For management of Graphic Cache, Graphic Manager supplies a series of interfaces: graphic object cache size settings, swap graphic in, swap graphic out, swap timer, etc.

  • Contents of graphic cache

Graphic cache includes two parts: one is the image that presents to user, namely graphic’s bitmap or metafile A; the other is when graphic is registered or unregistered, the image that dynamically existing, it is the graphic before it transforming to bitmap or metafile, namely B.

  • Settings of graphic cache

Image that presents to user, namely graphic’s bitmap or metafile A, its size can be set through interface. Below is conventional diagram.

  • Swap in/out of temp file

Graphic that before it transforming to bitmap or metafile, namely B. For its memory management, there is only one copy in memory, no matter how many times it is be used. In addition, it will be swapped in memory as temp file only when the graphic is present to user, that is to say, you can see it with your eyes. When move to next page, it will be swapped out to disk again.

3.3. Optimization of graphic cache

Sample file: document that contains lots of graphic (bmp, jpg, wmf) in it.

Root cause: Graphic will be swapped in memory as temp file only when the graphic is present to user, that is to say, you can see it with your eyes. When move to next page, it will be swapped out to disk again.

Solution: Do limit on memory B’s size. In order to avoid frequently swapping in/out, do limit on B like A, a max memory M will set to B. If exceeding M, the swap out and vice versa. This method can improve saving performance by 20%.

Personal tools