Issue 100172 - performance: framework::KeyMapping should be reused
Summary: performance: framework::KeyMapping should be reused
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: OOO310m5
Hardware: All All
: P3 Trivial (vote)
Target Milestone: OOo 3.1
Assignee: stefan.baltzer
QA Contact: issues@framework
URL:
Keywords: aqua, performance, regression
Depends on:
Blocks: 98052 95768
  Show dependency tree
 
Reported: 2009-03-13 11:03 UTC by hdu@apache.org
Modified: 2009-05-08 10:01 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description hdu@apache.org 2009-03-13 11:03:22 UTC
While debugging into issue 98052 I noticed that a lot of cycles in that use case (first keypress in empty 
Writer) are completely wasted by framework::KeyMapping objects. Since the implementation of that 
class only seems to deal with constant data rebuilding the key<->name maps shouldn't be done each 
time. Also the query methods in that class should be const-ified, as they don't change the KeyMapping 
object. Maybe the class should be pImpled and the const pImpl-entation should be reused.

Especially the method XCUBasedAcceleratorConfiguration::impl_ts_load() seems to be infamous for 
constructing/destructing the currently expensive KeyMapping object over and over. In the use case 
mentioned above (first keypress in Writer) this was done 5460 times!!!

Here is a simple patch to reduce the thousands of invocations to one by reusing the (to-be const) 
object:
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -1287,1 +1287,1 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( sal_Bool bPreferred, 
const
-            KeyMapping aKeyMapping;
+            static KeyMapping aKeyMapping;
Comment 1 carsten.driesner 2009-03-13 11:13:42 UTC
cd->wuyan: Could you please have a look at this issue. This is a performance
problem for all platforms although the Mac is hurt most.
Comment 2 eric.bachard 2009-03-14 09:34:03 UTC
@hdu : I discussed the point two days ago with pl, and you come with a patch :)

I'll test it immediately, because I'm very curious to see this problem solved.

Comment 3 eric.bachard 2009-03-14 09:34:24 UTC
+me on CC
Comment 4 carsten.driesner 2009-03-16 09:21:59 UTC
cd->hdu: As discussed by phone. KeyMapping can be removed from the inner loop.
You can also make this variable static.

cd: Add regression keyword. Ok in OOo 3.0.1.
Comment 5 wuyan.ooorg 2009-03-16 09:45:05 UTC
wuyan->cd,hdu: THANKS for the patch. Just as methioned aboved, much resource was
consumed due to the KeyMapping ctor/dtor in the loop but I ignored that. Both
the two solutions could solve this problem.
Comment 6 carsten.driesner 2009-03-16 12:59:37 UTC
cd: Set correct target. Approved as show stopper.
Comment 7 hdu@apache.org 2009-03-16 14:38:03 UTC
code change reviewed => ok
Comment 8 carsten.driesner 2009-03-16 17:20:05 UTC
cd: Fixed.
Comment 9 carsten.driesner 2009-03-16 17:21:29 UTC
cd->sba: Please verify.
Comment 10 stefan.baltzer 2009-03-20 17:46:58 UTC
Verified in CWS fwk106.
Comment 11 stefan.baltzer 2009-05-08 10:01:09 UTC
OK in OOO310_m11 (OOo 3.1). Closed.