Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Virtual SWT tables behaving very slowly on linux platforms
Virtual SWT tables behaving very slowly on linux platforms [message #628498] Thu, 23 September 2010 09:02 Go to next message
Quentin D. is currently offline Quentin D.
Messages: 1
Registered: September 2010
Junior Member
Hello,

We have to display a really big number of events in a table. We thus decided to use virtual tables (SWT.VIRTUAL).

On Windows (Win XP), it works very well, even with 10 million items.
But we need to create a portable application. So we tested our virtual table on RedHat Enterprise Linux 3 and 4, and we are facing serious execution time issues.

Our test class is an Eclipse view containing a virtual table.
For 2 million items : the table takes 20 seconds to display, and navigation with the scrollbar is very slow.
For 1 million items : 10 seconds to display, and navigation almost acceptable.

Whereas, on Windows, all works perfectly, even for 10 million items.

How could we explain this difference? Is there a known solution for this issue?

We tested the virtual table on GTK-2-2.2.4-4.0, GTK-2-2.2.4-19, and GTK2-2.4.13-22.

Thanks a lot.
Best regards.

public class ViewPart1 extends ViewPart {
	
	public ViewPart1() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void createPartControl(final Composite parent) {
		// Define a vertical layout
		FillLayout fillLayout = new FillLayout();
		fillLayout.type = SWT.VERTICAL;
		parent.setLayout(fillLayout);
		
		// Create and fill an array containing the text of the lines we
		// insert in the table
		int COUNT = 10000000;
	 	
	 	// Create the table and the label
	 	final Table table = new Table(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
		table.setLinesVisible (true);
		table.setHeaderVisible (true);
		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
		data.heightHint = 200;
		table.setLayoutData(data);
		String[] titles = {"C1", "C2", "C3", "C4", "C5", "C6"};
		for (int i=0; i<titles.length; i++) {
			TableColumn column = new TableColumn (table, SWT.NONE);
			column.setText (titles [i]);
			column.setWidth(200);
		}
	 	
	 	final Label info = new Label(parent,SWT.NONE);
	 	final Button button = new Button(parent, SWT.NONE);
	 	button.setText("table.clearAll();");
	 	
	 	// Define a listener to fill the required new lines of the table
	 	table.addListener(SWT.SetData, new Listener() {
	 		int nbLoaded = 0;
	 	    public void handleEvent(Event event) {
	 	       TableItem item = (TableItem)event.item;
	 	       int index = event.index;
	 	       // Get the text from the itemStrings[] array
	 	       nbLoaded++;
	 	       item.setText(0,"item " + index);
	 	       item.setText(1,"item " + index);
	 	       item.setText(2,"item " + index);
	 	       item.setText(3,"item " + index);
	 	       item.setText(4,"item " + index);
	 	       item.setText(5,"item " + index);
	 	       info.setText("Item " + index + " loaded from array \"itemStrings[]\" (total " + nbLoaded + ")");
	 	    }
	 	});
	 	table.setItemCount(COUNT);
	 	
	 	Listener listener = new Listener() {
	 	   public void handleEvent(Event event) {
	 		  table.clearAll();
	 	   }
	 	};
	 	button.addListener(SWT.Selection,listener);
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub
	}

}
Re: Virtual SWT tables behaving very slowly on linux platforms [message #628789 is a reply to message #628498] Fri, 24 September 2010 03:43 Go to previous messageGo to next message
Lakshmi Shanmugam
Messages: 274
Registered: July 2009
Location: India
Senior Member
Hi,

I think this is a known issue. Please see this bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=236863


Lakshmi P Shanmugam
Re: Virtual SWT tables behaving very slowly on linux platforms [message #629874 is a reply to message #628789] Wed, 29 September 2010 15:48 Go to previous messageGo to next message
Michal Niewrzal is currently offline Michal Niewrzal
Messages: 22
Registered: July 2009
Junior Member
I have also problem with VIRTUAL viewer. I have created virtual tree with columns. On windows scroll works smooth but on linux and gtk is very slow. To show my problem i have modify Snippet047VirtualLazyTreeViewer snippet. Unmodified example works fine but when I have added columns everything starts to work very slow.

I work on Eclipse 3.6 and Linux Mint Xfce with GTK 2.20.1. I had this problem also on Fedora 12. My machine have Dual-Core 2x2.0 and 3GB DDR3 so this is not hardware problem Smile

I look for solution for some time and I will be grateful for any tips Smile

package pl.wywrzal.trial;

import org.eclipse.jface.viewers.ILazyTreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * A simple TreeViewer to demonstrate usage of an ILazyContentProvider.
 * 
 */
public class Snippet047VirtualLazyTreeViewer {
	private class MyContentProvider implements ILazyTreeContentProvider {
		private TreeViewer viewer;
		private IntermediateNode[] elements;

		public MyContentProvider(TreeViewer viewer) {
			this.viewer = viewer;
		}

		public void dispose() {

		}

		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
			this.elements = (IntermediateNode[]) newInput;
		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see
		 * org.eclipse.jface.viewers.ILazyTreeContentProvider#getParent(java
		 * .lang.Object)
		 */
		public Object getParent(Object element) {
			if (element instanceof LeafNode)
				return ((LeafNode) element).parent;
			return elements;
		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see
		 * org.eclipse.jface.viewers.ILazyTreeContentProvider#updateChildCount
		 * (java.lang.Object, int)
		 */
		public void updateChildCount(Object element, int currentChildCount) {

			int length = 0;
			if (element instanceof IntermediateNode) {
				IntermediateNode node = (IntermediateNode) element;
				length = node.children.length;
			}
			if (element == elements)
				length = elements.length;
			viewer.setChildCount(element, length);

		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see
		 * org.eclipse.jface.viewers.ILazyTreeContentProvider#updateElement(
		 * java.lang.Object, int)
		 */
		public void updateElement(Object parent, int index) {

			Object element;
			if (parent instanceof IntermediateNode)
				element = ((IntermediateNode) parent).children[index];

			else
				element = elements[index];
			viewer.replace(parent, index, element);
			updateChildCount(element, -1);

		}

	}

	public class LeafNode {
		public int counter;
		public IntermediateNode parent;

		public LeafNode(int counter, IntermediateNode parent) {
			this.counter = counter;
			this.parent = parent;
		}

		@Override
		public String toString() {
			return "Leaf " + this.counter;
		}
	}

	public class IntermediateNode {
		public int counter;
		public LeafNode[] children = new LeafNode[0];

		public IntermediateNode(int counter) {
			this.counter = counter;
		}

		@Override
		public String toString() {
			return "Node " + this.counter;
		}

		public void generateChildren(int i) {
			children = new LeafNode[i];
			for (int j = 0; j < i; j++) {
				children[j] = new LeafNode(j, this);
			}

		}
	}

	public Snippet047VirtualLazyTreeViewer(Shell shell) {
		final TreeViewer v = new TreeViewer(shell, SWT.VIRTUAL | SWT.BORDER);
		v.getTree().setBackgroundMode(SWT.INHERIT_DEFAULT);
		v.getTree().setHeaderVisible(true);
		v.getTree().setLinesVisible(true);

		for (int i = 0; i < 15; i++) {
			TreeViewerColumn column = new TreeViewerColumn(v, SWT.NONE);
			column.getColumn().setResizable(true);
			column.getColumn().setWidth(80);
		}

		v.setLabelProvider(new LabelProvider());
		v.setContentProvider(new MyContentProvider(v));
		v.setUseHashlookup(true);
		IntermediateNode[] model = createModel();
		v.setInput(model);
		v.getTree().setItemCount(model.length);

		v.expandAll();
	}

	private IntermediateNode[] createModel() {
		IntermediateNode[] elements = new IntermediateNode[10];

		for (int i = 0; i < 10; i++) {
			elements[i] = new IntermediateNode(i);
			elements[i].generateChildren(1000);
		}

		return elements;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());
		new Snippet047VirtualLazyTreeViewer(shell);
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}

		display.dispose();

	}

}

Re: Virtual SWT tables behaving very slowly on linux platforms [message #629882 is a reply to message #629874] Wed, 29 September 2010 16:25 Go to previous message
Michal Niewrzal is currently offline Michal Niewrzal
Messages: 22
Registered: July 2009
Junior Member
I think I found what is causing my problems https://bugs.eclipse.org/bugs/show_bug.cgi?id=323430
Previous Topic:Wizard page - when to use pack()?
Next Topic:how to create a shell non-activated?
Goto Forum:
  


Current Time: Thu Jul 24 19:04:36 EDT 2014

Powered by FUDForum. Page generated in 0.01558 seconds