JDK-6228914 : perf: IM native calls
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt:i18n
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-02-14
  • Updated: 2010-04-02
  • Resolved: 2005-03-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b28Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Please see the attached performance log.  It was 
produced by running SwingMark 15 times with XAWT on Linux(SuSE 9.1).  Please notice the
results produced by setXICFocusNative - it consumed almost 9% of all
EventQueue's ticks!  Since SwingMark was run 15 times, and there is only
one focused window, I would expect it to be around 15 ticks (all
consecutive calls are basically no-ops, one tick per call based on the
performance of other X calls seems enough).  Looking at the native code,
I see two problems:
- it doesn't check if the focus has already been set to the same
window.  Perhaps it is being checked somewhere before, but this needs to
be verified
- it calls XSync - almost all the time!  XSync may be removed, or
replaced with XFlush, or at least called only when window changes
- do we really need these calls in en_US.UTF-8 locale?

The steps to reproduce the problem:

1.  Get refworkload from alacrity.sfbay
2.  Run benchmarks/swingmark with "java -Xprof SwingMark -r 15"
###@###.### 2005-2-15 10:26:18 GMT

Comments
EVALUATION One thing we could do is to rewrite native code in Java, like other XAWT components do, and only call real X call wrappers. This should eliminate unnecessary native calls. ###@###.### 2005-2-14 18:35:25 GMT RFE 6228989 is filed for rewriting the XAWT part of the input method native code. The root cause of this bug is when awt/swing component looses the focus, sun.awt.X11InputMethod.deactive is called to reset the XIC focus for the current focussed component and when another awt/swing component gains the focus, it calls the activate to set the XIC focus for the newly focussed component. For Swing component, since all the sub-components shares the same underlying XIC, there is no need to reset and set the XIC focus again and again. And these calls are quite expensive. The solution is to : 1. Delay resetting the XIC focus when deactivate is called and record the current XIC focussed component. 2. When activate is called, compare the current focused component peer with the saved XIC focussed component peer. If they are same, no need to take any actions (calling setXICFocus). Otherwise, reset the old XIC focus and set the XIC focus for the new focussed component. This will address the problem. However, it is important to mention that if the native IME (or XIC focus) is not reset when deactivate is called on the WInputMethod (X11InputMethod) and if the focus is switched to the non-clients, the non-clients may be able to use the native IME to input foreign characters. To solve this, we need to explicitly turn off the native IME (reset XIC focus) when focus is transferred to the non-clients. Since only at java.awt.Component level, the non-clients can be identified. We added a new method in sun.awt.im.InputContext to disable the native input method explicitly. ###@###.### 2005-2-18 18:58:58 GMT ###@###.### 2005-2-28 23:07:36 GMT ###@###.### 2005-03-03 19:57:06 GMT
14-02-2005