Bug 236863 - SWT.VIRTUAL Table.setItemCount() underperforms
Summary: SWT.VIRTUAL Table.setItemCount() underperforms
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Bogdan Gheorghe CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-12 09:29 EDT by Andreas Hauser CLA
Modified: 2019-07-11 13:18 EDT (History)
8 users (show)

See Also:


Attachments
GTK test application (1.84 KB, text/plain)
2017-05-12 07:35 EDT, Marc Strapetz CLA
no flags Details
SWT test application (3.51 KB, application/octet-stream)
2017-05-12 07:35 EDT, Marc Strapetz CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Hauser CLA 2008-06-12 09:29:54 EDT
Build ID: I20080609-1311

Steps To Reproduce:
1. Make a virtual Table with enough items (say 3 Million).
2. Wait say 20 seconds for setItemCount().

More information:
As far as i understand the problem is that for each item is preallocated, which kinda defeats the purpose of being virtual.


import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class setitemcount {
	static final int ROWS = 3000000;
	public static void main (String [] args) {
		final Display display = new Display ();
		Shell shell = new Shell (display);
		shell.setLayout (new FillLayout ());
		final Table table = new Table (shell, SWT.VIRTUAL);
		table.setHeaderVisible (true);
		table.addListener (SWT.SetData, new Listener () {
			public void handleEvent (Event e) {
				TableItem item = (TableItem) e.item;
				item.setText ("test");
			}
		});
		TableColumn column = new TableColumn (table, SWT.NONE);
		column.setText ("Column 1");
		column.setWidth (80);

		long start = System.currentTimeMillis();
		table.setItemCount (ROWS);
		System.out.println("" + (System.currentTimeMillis() - start) + "ms");

		shell.open ();
		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}
		display.dispose ();
	}
}
Comment 1 Steve Northover CLA 2008-06-12 11:47:28 EDT
This might be the best we can do.  GTK doesn't directly support virutal tables.  Can you include the GTK version and the hardware and memory specs for your machine?
Comment 2 Andreas Hauser CLA 2008-06-14 14:45:07 EDT
This is a Core2Duo (T5300 @ 1.73GHz) Notebook with 2.5GB RAM (DDR2-667MHz) running Archlinux 32bit.
The GTK version is 2.12.9.
Comment 3 Eric Williams CLA 2017-03-14 14:37:21 EDT
Performance on GTK3.22 is ~7 seconds.

As comment 1 mentions, this is pretty good considering GTK doesn't officially support lazy loading.

Due to age I am going to close this bug, as I don't think it's reproducible. Please feel free to file a new bug if the issue persists.
Comment 4 Thomas Singer CLA 2017-05-11 03:39:04 EDT
Please also take a look at this analysis: http://stackoverflow.com/a/43792401/241453
Comment 5 Marc Strapetz CLA 2017-05-11 03:44:16 EDT
There has been done a detailed analysis which points out some possible SWT improvements regarding reduction of native calls, but finally boils down to the already mentioned problems in GTK design:

http://stackoverflow.com/a/43792401
Comment 6 Eric Williams CLA 2017-05-11 21:38:28 EDT
(In reply to Marc Strapetz from comment #5)
> There has been done a detailed analysis which points out some possible SWT
> improvements regarding reduction of native calls, but finally boils down to
> the already mentioned problems in GTK design:
> 
> http://stackoverflow.com/a/43792401

I am not sure how much can be done about the locking and unlocking. I think it merits some investigation but our hands are tied by GTK.
Comment 7 Marc Strapetz CLA 2017-05-12 07:35:03 EDT
Created attachment 268312 [details]
GTK test application
Comment 8 Marc Strapetz CLA 2017-05-12 07:35:53 EDT
Created attachment 268313 [details]
SWT test application
Comment 9 Marc Strapetz CLA 2017-05-12 07:40:32 EDT
I've received more details from the author of the SO answer: I've attached an SWT test application for which Table.setItemCount() can be switched between 3 and 10M rows and a GTK test application which simply fills a GtkListStore with 10M rows. According to the author, in his VM switching from 3 to 10M rows in the SWT test application takes ~83s, populating the GtkListStore takes ~15s.