Free Support Forum - aspose.com

Barcode reading not performant in parallel processing

I am using the licensed barcode reader with .net and reading barcodes from images. When reading 1 by 1, it takes maybe 10 seconds for each image to get the results. When changing this to process multiple images at the same time with Parallel.ForEach and MaxDegreeOfParallelism of 10, the time taken for each image is anywhere between 20 and 60 seconds. Strangely, the total time for the same number of images is the same if serial or parallel (approximately).
What is it in the Aspose.Barcode component that needs to be set that will allow the multiple thread (parallel) version to perform each image analysis in the same few seconds as the serial method?

It already uses multi-threading recognition for single image (but not for all barcode types) and it can utilize well 6-8 processor cores. So you need more processor cores.

Thanks for the reply. If my server has 15-20 cores, are you saying I can realistically expect to be able to do 2 images in parallel and no more?
How much of a difference does this make? And is it False by default?
BarCodeReader.ProcessorSettings.UseAllCores = true;
If I set the max threads with this setting, how is the setting used (in combination with above)?
BarCodeReader.ProcessorSettings.MaxAdditionalAllowedThreads = settings.MaxAdditionalAllowedThreads;
Thanks.

Currently we use ThreadPool for this on .net/core systems. And it is sensitive to SetMinThreads, SetMaxThreads options because additional threads we get from this pool.

We use multi-threading by default and in default values(ProcessorSettings.UseAllCores) we use ProcessorCount cores amount.

However not all barcode recognition algorithm use multi-threading(needs to be added) and have some restriction to usage of all provided cores (depends on image difficulty and amount of barcodes on it).

To utilize all cores you can set:
UseAllCores = false (we use UseOnlyThisCoresCount instead)
UseOnlyThisCoresCount = ProcessorCount (allowed threads for single recognition task)
MaxAdditionalAllowedThreads = ProcessorCount * 4 (max addition tasks)

And run in parallel one barcode recognition task for every 4-6 cores.