pts / pdfsizeopt

PDF file size optimizer
GNU General Public License v2.0
750 stars 65 forks source link

running multiple instances of pdfsizeopt at the same time #129

Closed nigelnquande closed 1 year ago

nigelnquande commented 5 years ago

I have written a wrapper application (in Java) that, given a root directory, extracts a list of paths to PDFs in that directory and subdirectories. It then creates a Process call for each file in the list. Currently, it uses pdfsizeopt.single in a single thread. Given that I have a large number of files (over 2000), I would like to create a new thread for each file (using some sort of thread management to ensure that no more than cpuCoreCount -1 threads are running at any one time) to speed up the process (which can spend over an hour per file on large files, upwards of 200 MB).

From what I understand, pdfsizeopt.single doesn't support using multiple threads. Is it possible to use the application from multiple threads (concurrent execution of multiple instances)? Would using a unique --tmp-dir flag for each file be sufficient to prevent clashes?

ksadjad commented 4 years ago

This is a very important topic

pts commented 1 year ago

From what I understand, pdfsizeopt.single doesn't support using multiple threads. Is it possible to use the application from multiple threads (concurrent execution of multiple instances)?

This is already possible. The reason why it works is that for each temporary file, pdfsizeopt adds the process ID to the filename, so concurrent executions don't try to read and write the same file.