Performance problems with gtk_tree_store_set()
Problem description:
Iterating through an entire TreeStore
and setting all its elements to an new value shows unexpected performance problems that seem to grow quadratically with the number of elements in the TreeStore
.
For example, setting 15000 elements containing UINT64
values takes gtk about 350 milliseconds on my machine.
I plotted the situation:
- x-axis: Number of elements
- y-axis (blue): Number of milliseconds to set them all
- y-axis (red): quadratic curve with constant factor fitted to blue line
Expected behaviour:
For 15000 UINT64
elements, I would expect no more than 3ms processing time on a desktop CPU, and that would already be a lot. Judging from the API, I would expect that setting n
elements would be O(n)
, so, setting the value of one element would be O(1)
.
Problem reproduction:
https://github.com/BenjaminRi/gtk_treemodel_perf_c
Build with ./compile.sh
, start with ./treemodel_perf
The program prints out the number of elements, a comma, and then the number of milliseconds it took to set all the elements.
Version information:
gtk3-3.24.8-1
Seems to happen with any gtk3 version that has been tried so far. Seems to happen on Windows, Linux and possibly other OSes.
Notes:
Discovered via gtk-rs, the Rust gtk wrapper. Behaviour is the same in C and Rust. https://github.com/gtk-rs/gtk/issues/1000
Please let me know if I overlooked performance documentation or if this is expected behaviour. I'm not very experienced with gtk and I couldn't find anything about this issue.