python-mss
python-mss copied to clipboard
Improve speed on GNU/Linux with XShm
XShm seems a good use for improving speed on GNU/Linux.
See https://stackoverflow.com/a/43500537/1117028 for a idea of implementation.
We could also find valuable information here: http://www.rahul.net/kenton/perf.html
The goal is to let MSS find the best implementation to use at initialization
Any update on this? Would be nice to run a quick comparison to see if there's a real benefit. Currently on Ubuntu.
Found an SO comment on how using XShmGetImage can be faster than XGetImage, maybe worth a read: https://stackoverflow.com/questions/30200689/perfomance-of-xgetimage-xputimage-vs-xcopyarea-vs-xshmgetimage-xshmputima#comment79301257_30200689
Quoted:
you should use XShmGetImage+XShmPutImage. With XGetImage, your program will allocate memory and receive the image data from the X server through the X server pipe. As you've seen you have to XFree() the allocated memory every time. With XShmGetImage+XShmPutImage you pre-allocate a shared memory region that will be used every time you call XShmGetImage, so you don't need to allocate+free every time. Plus since the memory is shared, the X server simply copies the image data to the memory you allocated, no need to send the data through the pipe.
That would be a great improvement, indeed. I am just lacking of time and motivation. But since you are in need for that feature, I will be able to work on it. It will not be for tomorrow though ;)
Of course, if you want to give a try, it would be awesome :)
That's alright, no stress. It could be a good nice to have is all, MSS already is pretty performant. I too lack time, maybe not motivation but definitely the skill to walk the walk lol.
Hi, I am interested as well !
Seems the 2nd URL in the OP is down. Wayback machine has it at https://web.archive.org/web/20191107002534/http://www.rahul.net/kenton/perf.html.