I've been writing a Kivy graphical program on Raspberry Pi, with the KivyPie OS (Linux pre-configured for Kivy development).
For some reason, it's running extremely slow if started with sudo.
Normally, running "python main.py", the program runs at about 30 cycles per second.
However, if I do "sudo python main.py", it runs as slowly as 1 cycle per 5-10 seconds.
I need to use sudo to access Raspberry's GPIO. (unless I try some other way to do it, that I see people discuss).
I'm interested, though, what could be the cause of such a massive performance drop with sudo? And is it possible to work around that?
PS: Running the same program on my PC (Linux) with and without sudo doesn't seem to cause such problem. Only on Raspberry.
Well, I would call this problem solved, even if a few questions remain.
Here are the key points:

The slowdown is caused by Kivy being unable to load the proper video driver under "sudo", and using software rendering instead.
I haven't figured out why the driver isn't loading with sudo or how to fix it. However...
After compiling the program with Pyinstaller, everything works fine. The executable can be started with sudo, GPIO is working, Kivy loads the appropriate driver, everything works fast, as it should.

To sum it up, the reason of the initial problem has been found, no fix for launching the program directly with Python was yet found, but the problem was removed by compiling the program with Pyinstaller. (still, not a convenient way for debugging.)
Raspberry Pi Python (Kivy) extremely slow with sudo