Python Multithreading Support via GIL#616
Conversation
Enabled parallel Python support by disabling the GIL during ReadBarcodes. This allows multiple threads to decode different images at the same time in Python.
|
Thanks for your contribution. Question: do you have a use case where this actually increases your throughput? If so, how big are your input images? |
|
I ran a few benchmarks, and the throughput improvement is nearly linear per core (I have 8 cores for the numbers below). For testing out the 200x193 I used 10k images and for the 1919x2670 I used 100 images. resolution (200, 193) Not sure how familiar you are with Python -- essentially with the GIL locked no other python code can execute in any other threads. My specific application is automated inspection in electronics manufacturing -- camera array scanning labels from panels of circuit boards. I need to scan ~40 barcodes in real-time, but it's grossly parallel. |
|
Thanks for your benchmarking information. Makes your change look obviously very worthwhile. :). If you care about performance, make sure you only look for symbologies ( |
Enabled parallel Python support by disabling the GIL during ReadBarcodes. This allows multiple threads to decode different images at the same time in Python.
pybind11 notes are here https://pybind11.readthedocs.io/en/stable/advanced/misc.html#global-interpreter-lock-gil