Loading liststore slow on Raspberry Pi 4

Loading a Gtk.Liststore is taking about 10x longer on a Raspberry Pi 4 than it takes on a NUC.

When I run Raspberry Pi OS (6.5.0-1006-raspi) and my own build of Python 3.11, I get times around 2200 ms.

When I run Ubuntu 23.10, I get times around 1800 ms.

On a NUC (Kubuntu 23.04), I get times around 240ms.

I am loading Python objects in the liststore (lists of tuples of strings).

Is it surprising to anyone else that the Raspberry Pi is so much slower? Does anyone have an idea why it is so much slower?

GtkListStore is deprecated, and indeed it might not be a very fast widget.

I’ve never used a Pi or a NUC but aren’t Pis flash storage and NUCs SATA? I’d expect a big latency difference because of that, especially if you are accessing the storage multiple times to perform a task.

edit: to give an idea of difference just to access a drive, for me at least…

nvme 0.03ms
sata ssd 0.09ms
usb3 flash 0.75ms

Loading from where? Memory? Storage?

Is the GtkListStore connected to a GtkTreeView, or are you just loading things first and then attaching the store object to a view widget?

Are you loading things in a tight loop, or are you loading chunks of data using something like an idle source inside the main loop?

In general, you really need to measure where the hotspots are, using something like sysprof or oprofile.

When I first noticed the problem, the data I was transferring to the liststore was stored on an SSD. I thought that the USB3 connection might be a problem, so I moved the data to the internal SD card. When that change did not help, I moved the data to ramdisk. Slow in every case.

I commented out the statement for actually appending the data to the liststore so that I was measuring the elapsed time just for transferring the data. On the NUC, I get numbers around 2-3 ms. When I append to the liststore, the numbers are around 240 ms. On the Raspberry Pi, I get numbers around 22 ms for the transfer alone and 2200 with the append to liststore.

I thought it interesting that both numbers for the Raspberry Pi are about 10x the numbers for the NUC. That observation made me wonder whether the Raspberry Pi was running at full speed. It was running at 0.6 GHz. The Intel CPU was at 2.4 GHz. The difference of 4x partly explains the 10x difference in execution time. It now seems plausible that the difference in performance can be attributed to the power of the CPUs. I am not sure about that conclusion because the speed of the CPU changes. Sometimes it is as high as 1.8 GHz on the Raspberry Pi.

To ebassi, no doubt my code can be optimized. I will explore your suggestions.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.