feat(docreader): speed up scanned-PDF parsing, stream image results, isolate heavy async queues
Large scanned PDFs (hundreds of pages) were slow and fragile end-to-end.
This change addresses the parse, transport, and task-scheduling layers:
docreader (parse + transport):
- Parallelize per-page scanned rendering across processes (forkserver/fork),
with serial fallback. ~4-7x faster on large scanned PDFs; pdfium is not
thread-safe so we fan out across processes. Configurable via
DOCREADER_PDF_RENDER_PARALLELISM.
- Add server-streaming ReadStream RPC: emit one meta frame then one frame per
image, so documents with many page images are no longer capped by the unary
gRPC message-size limit (a 874-page PDF produced ~193MiB of images, far over
the 50MB cap) and memory is bounded on both ends. Unary Read is kept for
backward compatibility; the Go production reader switches to ReadStream.
VLM:
- Make the VLM HTTP timeout configurable (VLM_HTTP_TIMEOUT_SECONDS) and raise
the default 90s -> 180s so dense scanned-page OCR does not time out with
"context deadline exceeded".
Async task queues:
- Isolate high-volume, model-heavy fan-out tasks into dedicated asynq queues so
a single large document cannot saturate the shared worker pool and block
user-facing document parsing:
image:multimodal -> "multimodal"
chunk:extract -> "graph"
question:generation -> "question"
- Register the new queues in the server weight map and the cancel inspector's
scanned-queue set (so cancelling a knowledge still purges its pending tasks).
This commit is contained in:
+15
-1
@@ -552,8 +552,22 @@ DOCREADER_TRANSPORT=grpc
|
||||
# 设为 0 可关闭对应限流;默认 1 更适合普通单机或 GPU 资源有限的部署
|
||||
# DOCREADER_MARKITDOWN_MAX_WORKERS=1
|
||||
# DOCREADER_PDF_RENDER_MAX_WORKERS=1
|
||||
# 单个 PDF 内部「扫描页渲染」的并行进程数。pdfium 非线程安全,故按进程并行,
|
||||
# 每个进程各自打开文档渲染分到的页。大体量扫描件串行渲染在 CPU 受限容器上可能
|
||||
# 耗时数小时,这是缩短该耗时的主要手段(实测 874 页 117s→30s/4 进程,→17s/8 进程)。
|
||||
# 默认随 CPU 核数自动取 min(4, cpu)。注意:容器需分配足够 CPU 才能吃到加速。
|
||||
# DOCREADER_PDF_RENDER_PARALLELISM=4
|
||||
# DOCREADER_PDF_RENDER_DPI=200
|
||||
# DOCREADER_PDF_JPEG_QUALITY=90
|
||||
# DOCREADER_PDF_JPEG_QUALITY=85
|
||||
# 渲染页图的最大长边像素(防止超大页面 PDF 渲染出 100+MP 图、撑爆 gRPC 消息上限)
|
||||
# 调小可进一步减小图片体积;过小会影响 OCR 识别(密集中文建议 >=1600)
|
||||
# DOCREADER_PDF_RENDER_MAX_EDGE=2000
|
||||
|
||||
# VLM(视觉模型)单次 HTTP 请求的整体超时时间(秒)。
|
||||
# 扫描件整页 OCR(全文+版式抽取)在慢端点上很容易超过默认值,
|
||||
# 出现 "context deadline exceeded (Client.Timeout exceeded while awaiting headers)" 时调大本值。
|
||||
# 默认 180。
|
||||
# VLM_HTTP_TIMEOUT_SECONDS=180
|
||||
|
||||
# 如果使用Weaviate作为向量存储,需要配置以下参数
|
||||
# 注意:容器内访问请使用 service:port(不要用 localhost,也不要用宿主机映射端口)
|
||||
|
||||
Reference in New Issue
Block a user