2020.12.30 15:15 "[Tiff] Multithreading support?", by OnlineCop

2020.12.30 15:26 "Re: [Tiff] Multithreading support?", by John

Does libtiff support (allow? provide API for?) multi-threading? I would like to read in a single 50-GB file and assign different threads/processes to extract the images.

Hello,

You can open the same file many times from different threads and they can all read different parts of the file, but you can't use a single TIFF* handle from more than one thread at the same time.

While using a different TIFF* handle for each thread will work, it can make caching awkward. An alternative approach is to have a mutex around libtiff and share one TIFF* handle between all threads, but only allow one thread at once to use it. Almost all CPU time during tile read will be spent in decompression, so as long as you move the decompress step outside the lock, this is pretty quick, and makes caching simple.

openslide is perhaps a useful example of moving decompression outside the lock -- they have jp2k-compressed tiles which are decoded in parallel, but access to libtiff is single-threaded and controlled with a mutex. You can't lift their code directly, of course, but it might be interesting to have a look at.

https://openslide.org/

You need the Aperio reader.

John