From 18b6f056572e8c1138e642080be4bd7b348263a5 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Wed, 18 Jan 2017 17:52:12 -0800 Subject: [PATCH] Resolve issue #124 - poor performance with Tesseract v4 It seems that Tesseract v4 on a platform with OpenMP working correctly while perform poorly with ocrmypdf because each will also soak up all available CPUs. Running N^2 processes/threads on a N-core CPU where each wants 100% of CPU turns out to be detrimental. So, we restrict ocrmypdf w/tessv4 to a single Tesseract process at a time, for now. Alternative may be to limit OpenMP threads if throughput is higher. --- ocrmypdf/pipeline.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ocrmypdf/pipeline.py b/ocrmypdf/pipeline.py index a4ea9ba7..ed8c5b59 100644 --- a/ocrmypdf/pipeline.py +++ b/ocrmypdf/pipeline.py @@ -892,6 +892,8 @@ def build_pipeline(options, work_folder, log, context): extras=[log, context]) task_ocr_tesseract_hocr.graphviz(fillcolor='"#00cc66"') task_ocr_tesseract_hocr.active_if(options.pdf_renderer == 'hocr') + if tesseract.v4(): + task_ocr_tesseract_hocr.jobs_limit(1) # Uses multi-core on its own task_select_image_for_pdf = main_pipeline.collate( task_func=select_image_for_pdf, @@ -951,6 +953,8 @@ def build_pipeline(options, work_folder, log, context): extras=[log, context]) task_tesseract_ocr_and_render_pdf.graphviz(fillcolor='"#66ccff"') task_tesseract_ocr_and_render_pdf.active_if(options.pdf_renderer == 'tesseract') + if tesseract.v4(): + task_tesseract_ocr_and_render_pdf.jobs_limit(1) # Uses multi-core # PDF/A task_generate_postscript_stub = main_pipeline.transform(