Repository navigation
perf: reuse the last scaled render for cropped get_image calls - #405
Closed
ExtReMLapin wants to merge 2 commits into
Closed
ExtReMLapin wants to merge 2 commits into
ExtReMLapin wants to merge 2 commits into
Conversation
Signed-off-by: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com>
Contributor
|
✅ DCO Check Passed Thanks @ExtReMLapin, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
PeterStaar-IBM
self-requested a review
October 12, 2026 13:53
Caching every non-default-scale render keeps one full page image per live page. Docling asks for full-page images at images_scale in preprocessing and at scale 2 for tables, and caches those itself in Page._image_cache, so the parser cache only duplicated them. On a 40-page scanned document with images_scale=2 that added about 330 MiB at peak. Keep the render only when the request has a cropbox, which is the OCR case this cache is for. A full-page request still reuses a cached render at the same scale. Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
cau-git
approved these changes
Oct 28, 2026
Member
|
@ExtReMLapin Thanks for this improvement. I made a small change such that this only fires for crop-requests. |
Member
|
@ExtReMLapin your work is now included in #429 with your original commits. I am therefore closing this PR. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PageParseResult.get_image(scale=..., cropbox=...)renders the whole page and then crops. Docling's OCR stage asks for one crop per OCR region, all at the same scale (3.0), so a page with N regions is rendered N times.Keep the last non-default-scale render next to
_default_image, which is already cached the same way.On a 5-page PDF where layout sends 11 regions to OCR (11 renders at 3x, 5 needed), docling conversion goes 2.77 s → 2.38 s (median of 5, A100). Output unchanged; docling's
tests/test_backend_docling_parse.pyand the RapidOCR e2e OCR test pass.Diagnosis, commit message, PR text and PR creation done with help from Claude.