perf: add low-overhead row decode APIs for Node.js#48
Merged
Conversation
Optimize the existing decodeRowsBuffer() with a column name cache that avoids recalculating column letters on every cell of every row. Add two new APIs for performance-sensitive workloads: - getRowsRaw() / decodeRowsRawBuffer(): returns cell data in flat typed arrays (Uint32Array, Float64Array, etc.) instead of JsRowData objects, eliminating per-cell/per-row object allocation entirely. - getRowsIterator() / decodeRowsIterator(): generator that yields one JsRowData at a time without materializing the entire array, reducing peak memory usage for sequential row processing. Includes 22 new tests covering all cell types, sparse data, large datasets, consistency with existing getRows(), and edge cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Owner
Author
|
Review finding (performance regression): column-name cache prewarm penalizes sparse/wide sheets.
For sparse buffers, this changes complexity from roughly O(non-empty-cells) column-name work to O(colCount). In this format, I reproduced this on a sparse wide sheet (
This also weakens iterator behavior: Suggested fix:
|
Only pre-warm the column name cache for dense layout where every column will be visited. For sparse layout, column names are now resolved lazily per encountered cell, restoring O(non-empty-cells) complexity instead of O(colCount). This also fixes decodeRowsIterator() doing non-trivial upfront work before first next(), preserving lazy/streaming semantics. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.
Summary
decodeRowsBuffer()eliminating redundant string computationsgetRowsRaw()API returning typed arrays instead of JS objects (zero per-cell object allocation)getRowsIterator()generator for lazy row-at-a-time processing without full materializationPerformance Impact
New APIs
Changes
packages/sheetkit/buffer-codec.ts: Column cache,decodeRowsRawBuffer(),decodeRowsIterator(), sharedparseBuffer()packages/sheetkit/index.ts:getRowsRaw(),getRowsIterator()methods +RawRowsResultexportpackages/sheetkit/__test__/index.spec.ts: 22 new tests across 4 describe blocksTest plan
🤖 Generated with Claude Code