Performance problems with gtk_tree_store_set()
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
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
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
./compile.sh, start with
The program prints out the number of elements, a comma, and then the number of milliseconds it took to set all the elements.
Seems to happen with any gtk3 version that has been tried so far. Seems to happen on Windows, Linux and possibly other OSes.
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.