Why is a very large virtual table so slow? [message #521442] |
Wed, 17 March 2010 15:43 |
Marton Sigmond 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 #521693 is a reply to message #521614] |
Thu, 18 March 2010 14:01 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03374 seconds