Skip to content

Raise per-pod PyMuPDF concurrency for batches of small PDFs #565

Open

Description

@suguanYang

Summary

Batches of small PDFs on staging are limited by a fixed per-pod PyMuPDF concurrency of 2. A lone small PDF finishes its PyMuPDF work in a few seconds, but a batch of tiny files stretched the slowest file to about 2 minutes because child jobs queued behind two saturated slots.

Please raise per-pod PYMUPDF_MAX_CONCURRENT, or scale the slot count with the number of concurrent parses, instead of keeping a fixed 2.

Measured window

  • Window: 2026-11-17 07:52–07:54 UTC.
  • Staging session eb1a310a-e0cc-40a6-82a8-12fb0dd40166 is only a time anchor for this window.

What ran

  • 19 parse jobs were all submitted in about 2.6 seconds (first POST /v2/jobs ~07:52:34.7Z, last ~07:52:37.3Z) and ran together on two worker instances (10 jobs on one, 9 on the other).
  • The caller's own submission concurrency cap of 6 only paced submission and was not the bottleneck.
  • Wall clock from first submit to last ready was about 2 minutes 19 seconds (last ready mark ~07:54:53Z).
  • Files were tiny: 14×1 page, 3×2 pages, one 6-page and one 7-page PDF, plus one txt and one xlsx.

Stage timings

  • Dominant stage was page_memory.profile (about 60s average, max ~76s) for the PDFs: classification, asset probe, page render, and text scan.
  • worker.parse.document averaged ~75s, max ~114s.
  • Result upload was 0.1–0.4s.
  • Outbound model HTTP averaged ~0.6s.

VLM gate was not the bottleneck

PageMemoryVlmLimiter default PAGE_MEMORY_VLM_MAX_INFLIGHT=16. This batch waited 1–17ms (one wait of 69ms) with peak inflight 6.

PyMuPDF pool

  • PYMUPDF_MAX_CONCURRENT default is 2 per pod (runtime_limits.read_pymupdf_max_concurrent / pymupdf subprocess pool). Logs showed pool_size=2.
  • 87 child jobs, each child elapsed about 3–5s. Functions included page render, text probe, asset probe, and page text bands.
  • One instance ran 47 jobs / ~215s of child time in ~109s of wall (2 slots saturated, about 99% of two-slot capacity).
  • The other ran 40 jobs / ~132s of child time in ~67s of wall (also saturated, about 99% of two-slot capacity).
  • Queue wait is inside stage timers because the pool apply blocks until a slot is free.

Ask

For batches of small PDFs, raise per-pod PYMUPDF_MAX_CONCURRENT, or scale the slot count with concurrent parses, instead of a fixed 2.

Activity

  1. added
    page-memory-pipeline
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    document-parsingpage-memory-pipeline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions