Hi everyone. I've been working on making the OpenMP stuff that
libmypaint does more compatible with Python-based tile access and the
Python interpreter's GIL. I'd love a code review of some fiddly
threading considerations before it hits master.

https://github.com/achadwick/libmypaint/commits/threadfun/mypaint-tiled-surface.c
https://github.com/achadwick/mypaint/commits/threadfun/lib/pythontiledsurface.cpp
https://github.com/achadwick/mypaint/commits/threadfun/lib/tiledsurface.py

Why am I doing this? Well the reasoning chain starts with
https://github.com/mypaint/mypaint/issues/390 which is currently
making the Windows builds we do laggy and horrible. I want to try
stroke rendering dispatch in its own Python-initiated thread so that
the GTK main thread doesn't have to divide its time between rendering
the paint-strokes to the model and compositing screen updates AND
processing incoming events, in the hopes that this will make the
Windows experience less lagged.

If MyPaint does that, it should release the GIL while libmypaint
renders dabs, so that the drawing delivery thread doesn't lock the
program while it waits for dab rendering to finish. That would reduce
performance to single-threaded-plus levels as at present, but with
threading overhead.

As soon as libmypaint code is running in parallel with MyPaint's
Python guts, the tiledict needs locking and the global picture needs a
proper consideration of tile batch access. MyPaint already does tile
processing in batches that scale according to the radius of the brush,
so I've pulled the data requests out of the tile loop so that they can
run as a batch with the GIL held. Then we drop the GIL and let
libmypaint chew on RAM while other things happen in Python-land.
Finally the GIL gets claimed again so we can do tile put-backs and
return the dirtied bbox.

Currently there's no data copy for a tile requested for write by C++/C
code, and I'm making the BIG assumption that numpy won't change its
location in RAM while the paint thread holds a reference to it. That's
sort-of the assumption we were making earlier, but now it *really*
matters ;)

-- 
Andrew Chadwick

_______________________________________________
Mypaint-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/mypaint-discuss

Reply via email to