perf: optimize XML hot-part deserialization with streaming and zero-copy#50
Merged
Conversation
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Nebu1eto
force-pushed
the
perf/phase2-xml-hotpart
branch
from
February 11, 2026 16:01
8250ff8 to
82ae33b
Compare
Switch read_xml_part from read_to_string + from_str to quick_xml::de::from_reader with a size-aware BufReader (up to 64 KB). This eliminates the intermediate String allocation for all XML parts. Optimize per-cell deserialization: CompactCellRef and CellTypeTag now use serde Visitor implementations that accept &str directly, avoiding a heap String allocation per cell reference and type attribute. Optimize SharedStringTable::from_sst to take ownership of plain-text String values via std::mem::take instead of cloning. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Nebu1eto
force-pushed
the
perf/phase2-xml-hotpart
branch
from
February 11, 2026 16:09
82ae33b to
c8e1571
Compare
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
Three targeted optimizations eliminating the primary allocation hotspots in the XML read path:
read_to_string+from_strwithfrom_reader(BufReader)for all XML parts, eliminating multi-MB intermediate String allocationsCompactCellRefandCellTypeTagusingvisit_str(&str)instead ofString::deserialize, eliminating 2 heap allocations per cellstd::mem::taketo move owned strings from parsed SST directly intoArc<str>, avoiding clone for plain-text entriesPerformance Impact (estimated for 100k x 20 workbook)
Changes
crates/sheetkit-core/src/workbook/io.rs:from_reader(BufReader)with adaptive capacity (8KB-64KB)crates/sheetkit-xml/src/worksheet.rs: CustomCompactCellRefVisitor+CellTypeTagVisitorcrates/sheetkit-core/src/sst.rs:std::mem::takefor plain-text SST entriesTest plan
🤖 Generated with Claude Code