Repository navigation
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Click Fix with cubic on a comment, or reply @cubic-dev-ai fix this, and cubic writes the fix.
View guided diff | Re-trigger cubic
|
We hit the xlsx memory limits in production and built this PR to try it. Sharing our numbers in case they help it land. Setup: dense invented workbooks (one sheet, numeric and shared-string cells), anydoc v0.2.4 vs this branch, built locally, CLI, peak RSS.
Without this, we split large workbooks into row blocks with our own code before calling anydoc. It works, but it's a lot of XML handling to maintain outside the parser. We'd love to see this merged. Happy to run more cases if useful. |
This branch has not been deployed
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.
Summary
Resolves two coupled failure/memory modes on real-world Excel workbooks (#156, #155):
xl/worksheets/sheet*.xmlviaquick_xml::NsReaderwithout building a DOM tree (src/formats/sheet/xlsx.rs)xlsx::parseloaded every worksheet throughPackage::optional_xml_part(parse_xml), allocating hundreds of thousands of smallElement/Attr/Nodeheap nodes (~240–400 B each).<row><c t="s"><v>0</v></c></row>, >2M XML nodes) trippedConvertError::ResourceLimit { limit: "max_xml_nodes" }(xlsx: resource limits hit on real workbooks with excess whitespace #156 shape 2) and fragmented per-threadptmallocarenas in multi-worker hosts such as Node'slibuvthreadpool (Node binding retains large XLSX RSS high-water per libuv worker #155).read_sheetnow streams worksheet events directly with reused cell buffers while preservinglimits::MAX_XML_DEPTH, BOM/encoding transcoding (to_utf8), entity/CDATA decoding (resolve_entity), inline<rPh>phonetic stripping, Transitional + Strict OOXML SpreadsheetML namespaces, hidden rows/columns, merge regions, and legacy VML<legacyDrawing>lookups.Package::evictinsrc/package/archive.rs)xlsxandxlsbonce streamed so multi-sheet workbooks do not retain every decompressedsheetN.xml/sheetN.binsimultaneously, while keepingPackage::total_readmonotonic soMAX_TOTAL_BYTESenforcement is unchanged.xlsx,xlsb, andxls(!text.trim().is_empty())Cell::is_empty()andrender_cellalready treat whitespace-only text (spaces, NBSP\u{a0}normalized byclean_text) as empty, yetSheetContent::cellspreviously admitted!text.is_empty()entries, inflatingboundsto millions of empty grid slots and trippingmax_grid_slots(xlsx: resource limits hit on real workbooks with excess whitespace #156)." padded "), and interior coordinates between real non-empty cells remain intact (the_grid_budget_spans_the_whole_workbookinvariant preserved).Verification
src/formats/sheet/xlsx.rs:whitespace_only_cells_do_not_widen_the_grid_extentspace_fill_dragged_past_the_dom_node_cap_streams_without_errordeeply_nested_worksheet_xml_still_trips_max_xml_depthinline_phonetic_runs_are_omitted_and_strict_ooxml_worksheets_streamcargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --locked(290 unit + 2 header_collision + 1 robustness + 9 corpus snapshot tests pass)Refs #156, #155
Summary by cubic
Streams worksheet XML in
xlsxviaquick_xml::NsReaderinstead of building a DOM tree, so workbooks with hundreds of thousands of rows no longer tripmax_xml_nodesor fragment heap arenas. The previous parser materialized every<row>/<c>as heap-allocatedElementnodes; it now keeps only the current row and cell state in memory.xlsxandxlsb, reference-counted so a part shared by multiple sheet entries is evicted only after the last one consumes it.xlsx,xlsb, andxls, matching howCell::is_empty()renders them; padded text like" padded "keeps its padding.Written for commit ab1fe0b. Summary will update on new commits.