After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 131019 - TreeStore has no decent performance on massive inserts
TreeStore has no decent performance on massive inserts
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: TreeView
2.4
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-01-09 16:15 UTC by Christof Petig
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.5/2.6


Attachments
reported at http://mail.gnome.org/archives/gtk-list/2003-March/msg00361.html (9.81 KB, text/c-source)
2004-01-09 16:37 UTC, Christof Petig
Details

Description Christof Petig 2004-01-09 16:15:15 UTC
As reported by several people on the net there seems to be a performance
problem with Gtk::TreeStore insertions.

I personally have seen more than 30seconds for inserting 10k lines when
generating a tree out of a linear multi-columned list. My std::map based
custom model manages 100k in less than 2 seconds (300MHz G3 powerpc).

I'm going to simplify my example down to one file.
Comment 2 Christof Petig 2004-01-09 16:48:11 UTC
See also the mailing list thread at
http://mail.gnome.org/archives/gtkmm-list/2003-October/msg00090.html

[I admit that I do no longer remember the exect timings but it was
simply too much and more O(N^2+) than O(N logN).]
Comment 3 Alfredo Kojima 2004-04-02 07:23:34 UTC
The problem is that gtkmm only has append() and insert_before() methods. 
I've talked to gtk+ developers and they say append() is O(n), as it iterates
through the whole tree/list until the end so it can insert something. 
For appending large amounts of rows, they suggested using insert_after() with
the iterator from the previous insertion.
Comment 4 Murray Cumming 2004-04-03 12:40:01 UTC
Did you have that conversation on a mailing list or irc? Who told you this?
Comment 5 Alfredo Kojima 2004-04-03 14:00:48 UTC
On IRC, I believe it was Federico Mena who told me that.
Looking at the gtk+ sources, the append function calls g_node_append(),
which indeed traverses the whole list of nodes until the end to insert the new node.
Comment 6 Murray Cumming 2004-04-04 09:26:29 UTC
OK, I have added ListStore/TreeStore::insert_after() in gtkmm 2.4. We already
have prepend() which might also be faster. Thanks for investigating.

Please reopen this bug if it is still a problem.
Comment 7 Christof Petig 2004-04-14 07:08:10 UTC
I remember that some people proposed a function which appends a line and sets
the values in one step (append which takes an array of GValues for the columns).
I do not remember whether this speedup proposal was realized [it wasn't].

Looks like gtk_tree_store_set[_valist] is most equivalent to the thing I
remember. This is not wrapped in gtkmm (as of CVS today).

Perhaps the additional speedup (only two gtk+ calls per line, instead of
(columns+1)) would warrant designing a type safe interface ... perhaps ... I
have no need for it yet.

Should I file this as a wish list bug?

Also the API would be non-trivial to design (most probably a container like
structure which checks the type and collects the GValues). This sounds like
gtk_tree store in disguise to me (and I doubt it would be more efficient than
gtk_tree_store_set_value).

[I should not cease to investigate whether my custom model still has much speed
benefits over a tree_store, I suspect massive (2M+) GValue::ref calls to be the
next bottleneck]