JDK-4952802 : postEvent perf. heavily depends on EventQueue length
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-11-12
  • Updated: 2005-12-01
  • Resolved: 2004-10-11
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 b08Fixed
Related Reports
Relates :  
Relates :  
Description
Name: ssR10077			Date: 11/12/2003

###@###.###
The following test-case shows the time needed to post the set of
events to EventQueue. As events can't be processed until the run()
method returns the EventQueue steadily grows when new event is posted.

import java.awt.*;
import java.awt.event.*;

public class PostEventPerf implements Runnable {
    final static int MAX_EVENTS = 1000;
    final static int MAX_SERIES = 10;
    
    public static void main(String[] args) {
        EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
        eq.invokeLater(new PostEventPerf());
    }
    
    public void run() {
        EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
        Frame frame = new Frame();
        long globalStart = System.currentTimeMillis();
        long globalElapsed = 0;
        for (int j = 0; j < MAX_SERIES; j++) {
            long startTime = System.currentTimeMillis();
            for (int i = 0; i <= MAX_EVENTS; i++) {
                eq.postEvent(new TestEvent(frame));
            }
            long elapsedTime = System.currentTimeMillis() - startTime;
            globalElapsed += elapsedTime;
            System.out.println("Group postEvent time:" + elapsedTime);
        }       
        eq.postEvent(new LastEvent(frame, globalStart));
        System.out.println("Global postEvent time:" + globalElapsed);
    }
        
    static class TestEvent extends AWTEvent {
        TestEvent(Component obj) {
            super(obj, -1);
        }
    }
    static class LastEvent extends AWTEvent implements ActiveEvent {
        long startTime;
        LastEvent(Component obj, long start) {             
            super(obj, -1);
            startTime = start;
        }
        public void dispatch() {
            long elapsedTime = System.currentTimeMillis() - startTime;
            System.out.println("Global executuion time:" + elapsedTime);
        }
    }    
}

The test shows the following results on [1xP3-866,W2K] with 1.5.0b26
Group postEvent time:41
Group postEvent time:110
Group postEvent time:160
Group postEvent time:280
Group postEvent time:531
Group postEvent time:821
Group postEvent time:1192
Group postEvent time:1542
Group postEvent time:1733
Group postEvent time:1912
Global postEvent time:8322
Global executuion time:8523

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang FIXED IN: mustang
10-09-2004

SUGGESTED FIX Split coalescing of different kinds of events. Has been fixed by ###@###.###, 04/06/07, see Comments section ###@###.### 2004-09-09
10-09-2004

EVALUATION Name: ssR10077 Date: 11/12/2003 The profile of EDT with java -Xprof option Flat profile of 11.56 secs (946 total ticks): AWT-EventQueue-0 ... Compiled + native Method 96.2% 812 + 0 java.awt.EventQueue.postEvent 0.2% 2 + 0 java.awt.EventQueue.postEvent 0.1% 1 + 0 PostEventPerf$TestEvent.<init> 0.1% 0 + 1 sun.awt.SunToolkit.flushPendingEvents 0.1% 1 + 0 java.awt.EventQueue.dispatchEvent 0.1% 1 + 0 java.awt.EventDispatchThread.pumpOneEventForHierarchy 0.1% 1 + 0 java.awt.Component.dispatchEventImpl 97.0% 818 + 1 Total compiled ... The slowdown is related to event coalescing. After removing the coalescing code the test results drasticaly change. Group postEvent time:10 Group postEvent time:20 Group postEvent time:0 Group postEvent time:0 Group postEvent time:0 Group postEvent time:0 Group postEvent time:0 Group postEvent time:0 Group postEvent time:0 Group postEvent time:0 Global postEvent time:30 Global executuion time:300 ====================================================================== We should try to fix this in mustang or earlier. ###@###.### 2003-11-26
26-11-2003