Skip to content

perf: cache the Redis folder key count; group aggregation parses numbers without copying - #1682

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
perf/redis-folder-count-groupings-parse
Oct 17, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
perf/redis-folder-count-groupings-parse

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

From a data-structure review (claims checked against the code).

  • RedisKeyFolderNode.totalKeyCount walked the whole subtree on every call, and the folder row calls it up to three times per rebuild (O(keys x depth) with nested open folders). It is now counted on first use and kept (late final); the engine hands out finished lists and does not change the tree afterwards.
  • GridGroupingsEngine._computeAggregation copied every cell with replaceAll(',', ''). It now uses the comma-aware parser of the selection stats (parseThousandsSeparated, documented as equal to the copy); anything it cannot read takes the old path, so results are unchanged. The @visibleForTesting on that parser is dropped since lib code uses it now.
  • Test: sums with thousands separators, padding, stray commas and a non-number.

@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit c2c7aa7 into dev Oct 17, 2026
15 checks passed
@ZhuchkaTriplesix

Copy link
Copy Markdown
Member Author

🔍 Post-Merge Code Review & Verification

LGTM! Excellent performance hardening across Redis folder trees and pivot calculations:

  1. Redis Folder Key Caching (redis_key_tree_engine.dart):

    • late final int totalKeyCount = _countKeys() correctly eliminates the $O(\text{keys} \times \text{depth})$ recursive recalculation on every widget rebuild during tree scrolling.
    • Follow-up note: allKeys remains a dynamic recursive traversal. If batch operations on folders become frequent in future UX iterations, we can consider lazy-caching it similarly.
  2. Zero-Copy Numeric Aggregation (grid_groupings_engine.dart):

    • Reusing GridSelectionCalcEngine.parseThousandsSeparated avoids intermediate String allocations during comma-separated numeric aggregation, while gracefully falling back to double.tryParse on edge cases.
    • Unit tests in data_grid_engines_test.dart cleanly verify comma-delimited sum calculations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant