Bug 103937 - Motif: Resizing a column in a large virtual table is extremely slow.
Summary: Motif: Resizing a column in a large virtual table is extremely slow.
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: Other Unix All
: P3 normal (vote)
Target Milestone: 3.2 M1   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2005-07-14 20:07 EDT by Mitch Rudominer CLA
Modified: 2006-01-25 01:20 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mitch Rudominer CLA 2005-07-14 20:07:14 EDT
On all Motif:
Make a virtual table with two or three columns and 20,000 rows,
each cell containing text of length about 20 characters.

Use the mouse to increase the width of the first column. The app will
hang for close to a full minute.

I played with the code a bit and managed to resolve the issue. My change seems
to work fine in my app, but I haven't thought about whether it is sufficiently
general. Below I have pasted the change I made. The basic idea is the
following. In the method Table.updateColumnWidth(), there is a loop that
iteratively calls TableItem.updateColumnWidth() for each item in the table.
In a virtual table, this will have the effect of filling in the data for
every row, which, I think, is causing the slowdown. Instead of this loop,
for a virtual table just do a clearAll(). Here is the code:

In the method Table.updateColumnWidth() replace

                for (int i = 0; i < itemsCount; i++) {
			items [i].updateColumnWidth (column, gc);
		}
                gc.dispose ();


with
	if ((style & SWT.VIRTUAL)== 0) {
		for (int i = 0; i < itemsCount; i++) {
			items [i].updateColumnWidth (column, gc);
		}
	}
	gc.dispose ();
	if ((style & SWT.VIRTUAL) != 0) {
	    clearAll();
	}
Comment 1 Grant Gayed CLA 2005-07-21 14:39:15 EDT
fixed > 0720

The problem was the filling of the full table on the column resize.   My test
snippet below went from taking ~6 seconds to essentially instantaneous after the
fix (perhaps my machine is faster than what you're testing on).  If you still
see slowness on your end then please reopen the report and attach a snippet like
the one below that shows the problem happening, thanks.

public class Main {
	static int counter = 0;
public static void main (String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setBounds(10,10,400,400);
	final Table table = new Table(shell, SWT.VIRTUAL);
	table.setBounds(10,10,300,300);
	new TableColumn(table, SWT.NONE).setWidth(100);
	new TableColumn(table, SWT.NONE).setWidth(100);
	new TableColumn(table, SWT.NONE).setWidth(100);
	table.setHeaderVisible(true);
	table.setItemCount(20000);
	table.addListener(SWT.SetData, new Listener() {
		public void handleEvent(Event event) {
			String thing = counter++ + "abcdefghijklmnopqrstuvwxyz";
			System.out.println(thing);
			((TableItem)event.item).setText(new String[] {thing, thing, thing});
		}
	});
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
	display.dispose();
}
}
Comment 2 Grant Gayed CLA 2005-07-21 14:39:45 EDT
*sigh* taking ownership first...
Comment 3 Grant Gayed CLA 2005-07-21 14:40:52 EDT
marking as FIXED, again
Comment 4 Tobias Schwarz CLA 2006-01-25 01:20:22 EST
is there any patch for 3.1 to solve this problem there?