Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Why is a very large virtual table so slow?(I tested a table with 10 columns and 1 million rows...)
Why is a very large virtual table so slow? [message #521442] Wed, 17 March 2010 15:43 Go to next message
Marton Sigmond is currently offline Marton SigmondFriend
Messages: 73
Registered: July 2009
Location: Hungary
Member
Hi,

I created a virtual table with 10 columns and 1 million rows.
Since the table was virtual, I was expecting a very smooth performance.
I thought that the performance should be affected only by the number of visible lines.

But what I got:
- First lines are loaded instantaneously
- Last lines are loaded very slowly (more then 12 seconds)

I provide my view below.

Please advise how could I make the table perform better.

Thanks,
Marton

package table.test;

import org.eclipse.jface.viewers.ILazyContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;

public class View extends ViewPart {
	public static final String ID = "table.test.view";

	private static final int NUM_COLUMNS = 10;
	private static final int NUM_ELEMS = 1000 * 1000;

	private TableViewer viewer;

	class ViewLazyContentProvider implements ILazyContentProvider {
		private final TableViewer viewer;

		ViewLazyContentProvider(final TableViewer viewer) {
			this.viewer = viewer;
		}

		@Override
		public void updateElement(final int index) {
			viewer.replace(index, index);
		}

		@Override
		public void dispose() {
		}

		@Override
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		}
	}

	class ViewLabelProvider extends LabelProvider implements
			ITableLabelProvider {
		public String getColumnText(Object obj, int index) {
			final int rowNum = (Integer) obj;
			final int colNum = index;
			return "(" + rowNum + ", " + colNum + ")";
		}

		public Image getColumnImage(Object obj, int index) {
			return getImage(obj);
		}

		public Image getImage(Object obj) {
			return PlatformUI.getWorkbench().getSharedImages().getImage(
					ISharedImages.IMG_OBJ_ELEMENT);
		}
	}

	/**
	 * This is a callback that will allow us to create the viewer and initialize
	 * it.
	 */
	public void createPartControl(Composite parent) {
		viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
				| SWT.V_SCROLL | SWT.VIRTUAL);
		viewer.setContentProvider(new ViewLazyContentProvider(viewer));
		viewer.setLabelProvider(new ViewLabelProvider());

		for (int i = 0; i < NUM_COLUMNS; i++) {
			final TableColumn col = new TableColumn(viewer.getTable(),
					SWT.NONE);
			col.setWidth(120);
			col.setText("Column " + i);
		}

		viewer.setInput(getViewSite());
		viewer.setItemCount(NUM_ELEMS);

		viewer.getTable().setHeaderVisible(true);
	}

	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
		viewer.getControl().setFocus();
	}
}


Best Regards,
Marton Sigmond
Senior Software Engineer
Re: Why is a very large virtual table so slow? [message #521499 is a reply to message #521442] Wed, 17 March 2010 19:24 Go to previous messageGo to next message
Austin Riddle is currently offline Austin RiddleFriend
Messages: 128
Registered: July 2009
Senior Member
Hi Marton,

Unless you are using a lazy content provider, the million rows of data are still being sent to the client upon load. The VIRTUAL flag optimizes the presentation of rows in the client-side widget, but the data processing overhead is all there.

You can use a LazyContentProvider if you have lots of data, but it is mainly intended for when you don't know how much data you have exactly.

The caveat is that it does not support sorting and in some cases it may be advantageous for you to manage paging of the data yourself using your own UI controls, instead of relying on the scroll bar.

Hope this helps.

Re: Why is a very large virtual table so slow? [message #521597 is a reply to message #521442] Thu, 18 March 2010 09:02 Go to previous messageGo to next message
Stefan   is currently offline Stefan Friend
Messages: 316
Registered: July 2009
Senior Member
Hi,

I'm curious: what use case do you have that makes it necessary to
display 1 million rows? I doubt that any user can handle such amount of
data.

Regards,
Stefan.
Re: Why is a very large virtual table so slow? [message #521614 is a reply to message #521442] Thu, 18 March 2010 10:15 Go to previous messageGo to next message
Marton Sigmond is currently offline Marton SigmondFriend
Messages: 73
Registered: July 2009
Location: Hungary
Member
Hi,

thank you for the answers.

Austin,
as you can see from the snippet above I use an ILazyContentProvider, but the performance is still not there. Did I miss something?

Stefan,
1 million rows might not be realistic, but it proves perfectly whether the algorithm is optimal or not.

How I see it:
if there are 10 visible rows of a million (or even a billion), then only those 10 should be queried. So I should not see any difference depending on which part of the table I am watching.

Unfortunately we need an optimal solution. The cost of unnecessary network usage is not affordable.

I appreciate any suggestion to achieve this.

Thanks,
Marton


Best Regards,
Marton Sigmond
Senior Software Engineer
Re: Why is a very large virtual table so slow? [message #521693 is a reply to message #521614] Thu, 18 March 2010 14:01 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Marton,

let me first make two points clear:

1. Only the items actually needed are sent over the wire, so there is no
cost of unnecessary network usage.

2. The extra processing time you observed only affects the client's
browser, not the server.

There is obviously room for optimization in the client-side Javascript
code, but we're trying to optimize for the obvious use cases. As Austin
and Stefan already pointed out, a table with a million lines or more
will hardly result in a usable web interface.

On my site, virtual tables respond rather quickly with row counts up to
~ 10^5. If that's not sufficient for you, please open an enhancement
request.

Best regards,
Ralf

Marton Sigmond wrote:
> Hi,
>
> thank you for the answers.
>
> Austin,
> as you can see from the snippet above I use an ILazyContentProvider, but
> the performance is still not there. Did I miss something?
>
> Stefan,
> 1 million rows might not be realistic, but it proves perfectly whether
> the algorithm is optimal or not.
>
> How I see it:
> if there are 10 visible rows of a million (or even a billion), then only
> those 10 should be queried. So I should not see any difference depending
> on which part of the table I am watching.
>
> Unfortunately we need an optimal solution. The cost of unnecessary
> network usage is not affordable.
>
> I appreciate any suggestion to achieve this.
>
> Thanks,
> Marton
Previous Topic:[ANN] RAP @ EclipseCon
Next Topic:Java/Javascript Bridge and SVG documents
Goto Forum:
  


Current Time: Tue Apr 16 08:24:55 GMT 2024

Powered by FUDForum. Page generated in 0.25165 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top