Skip to content

perf(redis): zero-allocation key tree building via index scanning #1523

Open

Description

@ZhuchkaTriplesix

Problem

In RedisKeyTreeEngine.buildTree (lib/features/redis/redis_key_tree_engine.dart), for every key label.split(':') and parts.sublist(0, parts.length - 1) are called.
For 50,000 keys, this creates ~350,000 heap objects (List<String>, sublists, string chunks), causing GC pressure and UI frame stalls during Redis tree expansion.

Solution

  • Replace split and sublist with index-based scanning using key.indexOf(separator, start).
  • Traverse and build trie maps directly without allocating intermediate lists.
  • Avoid unnecessary substring allocations for unmodified paths.

Benefits

  • 0 intermediate list allocations during tree construction.
  • ~4-5x speedup for large Redis databases (10k+ keys).

Activity

  1. added this to the 0.5.0 milestone on Oct 12, 2026
  2. added
    backendBackend database driver execution and queries
    connectionsDatabase connections, URI parsing, pools
    P2Medium priority / Parity & Refactoring
    on Oct 12, 2026
  3. added a commit that references this issue on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringbackendBackend database driver execution and queriesconnectionsDatabase connections, URI parsing, poolsenhancementNew feature or requestperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions