deepset-ai / deepset-ai/haystack
Add parallelization to our converters if there are noticeable performance gains
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 26.6k
- Forks
- 3.2k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 194
Description
Summary
Several file converters in haystack/components/converters/ process a list of sources sequentially. For workloads with many files, adding parallelism via ThreadPoolExecutor could significantly speed up processing.
This came up in the call with @bogdankostic and @ju-gu where we noticed that Sol is using thread-based parallelism to speed up PDF processing that can occur in a query pipeline when retrieving PDF files from a web search + content fetcher request.
Motivation
Converters currently iterate over sources one at a time in their run method. Depending on the nature of the work per file, parallel execution could provide meaningful speedups:
-
Network I/O-bound (highest gain):
TikaDocumentConverter- requires a synchronous call to an external service. Using a thread pool executor would greatly speed this up. -
File I/O + CPU parsing (good gain):
DOCXToDocument,PPTXToDocument,MSGToDocument,HTMLToDocument,XLSXToDocument,PDFToImageContent,ImageFileToImageContent- a mix of file reads (I/O, releases the GIL) and moderate CPU parsing. Threads would help primarily during the I/O phase. -
Typically CPU-bound PDF parsing (moderate gain):
PyPDFToDocument,PDFMinerToDocument- parsing is pure Python and the GIL limits thread-based parallelism.ThreadPoolExecutorstill helps by overlapping file reads across files, but if the pdf parsing is the dominant cost then this doesn't parallelize well with threads. -
Low priority:
TextFileToDocument,MarkdownToDocument,CSVToDocument,JSONConverter,FileToFileContent- per-item work is light enough that adding the executor is probably not worth the overhead.
Investigation needed
- Benchmark sequential vs.
ThreadPoolExecutorfor each converter category above - Determine appropriate default
max_workersvalues
👋 Hello there! This issue will be handled internally and isn't open for external contributions. If you'd like to contribute, please take a look at issues labeled contributions welcome or good first issue. We'd really appreciate it!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in haystack/components/converters/ and compare the run methods for TikaDocumentConverter, DOCXToDocument, PPTXToDocument, MSGToDocument, HTMLToDocument, XLSXToDocument, PDFToImageContent, and ImageFileToImageContent against the lower-priority converters. Benchmark sequential processing against ThreadPoolExecutor across the listed categories, then document whether gains justify it and the appropriate default max_workers values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100