fix: avoid 1M cells reserve to reduce memory footprint - #311
Merged
PeterStaar-IBM merged 2 commits intoAug 8, 2026
Merged
Conversation
Pre-allocating 1M cells per PAGE_CELLS container wasted ~300 MB per container. With 5 such containers per decoded page (page_cells, char_cells, cells, word_cells, line_cells) this multiplied to ~1.5 GB committed per page and OOMs on small docs when several pages were decoded concurrently. Let the vector grow on demand instead; typical pages have only hundreds to a few thousand cells. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
✅ DCO Check Passed Thanks @yonikremer, 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/
|
I, yoni kremer <yoni.kremer@gmail.com>, hereby add my Signed-off-by to this commit: 8922d06 Signed-off-by: yoni kremer <yoni.kremer@gmail.com>
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.
Pre-allocating 1M cells per
PAGE_CELLScontainer wasted ~300 MB per vector. With 5 such vectors per decoded page (page_cells,char_cells,cells,word_cells,line_cellsinsrc/parse/pdf_decoders/page.h:161-175) this multiplied to ~1.5 GB committed per page and OOMs on small docs when several pages decoded concurrently (threaded parser).Change (1 file):
src/parse/page_items/page_cells.h: removecells.reserve(1000000), let vector grow on demand (typical pages: hundreds to few thousand cells → <2 MB)Verified:
.venv/Scripts/python.exe -m pytest tests/test_parse.py -q→ 21 passed.venv/Scripts/python.exe -m pytest -q→ 111 passed, 1 pre-existing Windows path-separator failure_oom_perdoc.py: per-page delta 0-50 MB (worst 245 MB) vs previously 1.5 GB+Independent of the Windows/MinGW build PR.
🤖 Generated with Claude Code