Skip to content

Feature/memory range dimension#2306

Merged
JanKallman merged 3 commits intodevelop8from
feature/memory-range-dimension
Mar 5, 2026
Merged

Feature/memory range dimension#2306
JanKallman merged 3 commits intodevelop8from
feature/memory-range-dimension

Conversation

@swmal
Copy link
Contributor

@swmal swmal commented Mar 4, 2026

Performance: Virtual InMemoryRange for full column references

Formulas using full column references (e.g. $A:$A, B:B) in dynamic array expressions caused severe performance degradation. EPPlus materialized 1,048,576 rows regardless of actual data, resulting in millions of unnecessary allocations and iterations.

Changes

Virtual InMemoryRange — New concept separating physical size (backed by data) from logical size (full column). A _virtualDefaultValue field stores the pre-computed result for empty rows, avoiding per-cell allocation. Operators (+, *, =, &, etc.) compute the default once and propagate it through the chain.

MATCH/XlookupScannerGetMaxItemsRow now uses GetAddressDimensionAdjusted to limit search to physical rows instead of iterating 1M rows.

FormulaRangeAddress.HasFormulas — Loop clamped to worksheet dimension, eliminating 1M iterations per SUMIFS/AVERAGEIFS call with full column references.

Key files

  • InMemoryRange.cs — Virtual rows, default value propagation
  • RangeOperationsOperator.csSetVirtualDefault, SetVirtualDefaultForRanges
  • RangeHelper.csGetPhysicalRows
  • XlookupScanner.cs — Bounded search
  • FormulaRangeAddress.cs — Bounded HasFormulas

Result

Benchmark workbook: 10.8 minutes → 2.6 seconds (~250x improvement). Full test suite (6200+ tests) green.

@swmal swmal self-assigned this Mar 4, 2026
@swmal swmal added the enhancement New feature or request label Mar 4, 2026
@JanKallman JanKallman merged commit 691b387 into develop8 Mar 5, 2026
1 check passed
@JanKallman JanKallman deleted the feature/memory-range-dimension branch March 5, 2026 06:34
@github-project-automation github-project-automation bot moved this to Pending Release in Epplus Enhancements Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Pending Release

Development

Successfully merging this pull request may close these issues.

2 participants