Skip to content

perf(memory): introduce string interning pool for low-cardinality query results #604

Description

@ZhuchkaTriplesix

Problem

In database query results, many columns exhibit low cardinality (e.g. status codes like 'active', 'pending', booleans, enum values, country codes, category names).
Currently, convertResultRowsToStringsAdaptive in lib/core/database/result_row_string_convert.dart converts every cell into a standalone String instance. In a 50,000-row result set with repeated values, this creates tens of thousands of duplicate string objects in the Dart VM heap, consuming unnecessary memory.

Proposed Solution

  • Implement a lightweight, thread-safe string interning pool (e.g. StringPool / LRU deduplication map) during result row decoding in result_row_string_convert.dart.
  • Deduplicate frequently repeated string instances so identical values share the same String pointer in memory.
  • Add unit and memory benchmark tests demonstrating up to 40–60% heap reduction on low-cardinality test datasets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions