WeKnora/internal/infrastructure/docparser
wizardchen 7b1bb1054f 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).
2026-06-03 12:29:13 +08:00
..
builtin_converter.go fix(docparser): preserve standalone image uploads from icon filter 2026-04-29 11:58:02 +08:00
engine_registry.go refactor(weknoracloud): update credential handling and configuration 2026-04-15 11:37:24 +08:00
grpc_parser.go feat(docreader): speed up scanned-PDF parsing, stream image results, isolate heavy async queues 2026-06-03 12:29:13 +08:00
helpers.go feat(weknoracloud): implement credential management and status checks 2026-04-14 17:36:01 +08:00
http_parser.go feat(weknoracloud): implement credential management and status checks 2026-04-14 17:36:01 +08:00
image_resolver.go fix(docparser): address review feedback on PR #1404 2026-05-21 11:42:56 +08:00
image_resolver_relative_html_test.go fix(docparser): address review feedback on PR #1404 2026-05-21 11:42:56 +08:00
image_resolver_test.go feat: Add pending tasks and active status to WikiStats 2026-04-22 21:17:31 +08:00
json_converter.go feat(docparser): enhance sortedKeys function for numeric string sorting 2026-03-25 22:08:29 +08:00
json_converter_test.go feat(i18n): add JSON file type support across multiple locales 2026-03-25 22:08:29 +08:00
mineru_cloud_converter.go feat(weknoracloud): implement credential management and status checks 2026-04-14 17:36:01 +08:00
mineru_converter.go fix(docparser): address review feedback on PR #1404 2026-05-21 11:42:56 +08:00
mineru_converter_test.go fix(docparser): address review feedback on PR #1404 2026-05-21 11:42:56 +08:00
resolve_remote_images_test.go fix: improve tenant access token logging and update test cases 2026-04-22 21:17:30 +08:00
weknoracloud_http_reader.go feat(weknoracloud): implement credential management and status checks 2026-04-14 17:36:01 +08:00