Skip to content

perf(mongodb): string interning pool for BSON document tree keys and categorical values #1536

Closed as not planned

Description

@ZhuchkaTriplesix

Problem

In MongoDocumentTreeView (lib/features/mongodb/mongo_document_tree_view.dart), displaying large MongoDB collections allocates hundreds of thousands of duplicate string instances for common BSON keys (_id, createdAt, status, type, userId) across documents in the collection view.
This leads to high heap usage and garbage collection stalls during collection browsing.

Solution

  • Introduce a scoped StringInternPool in the MongoDB document tree engine.
  • Intern repetitive field names and frequent string values when converting and rendering BSON nodes.

Benefits

  • 35-50% reduction in memory consumption when browsing large MongoDB collections.
  • Smoother scrolling and tree expansion in document view.

Activity

  1. ZhuchkaTriplesix commented on Oct 12, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Closing: not supported by the code or by numbers.

    • MongoDocumentTreeView receives already-decoded Maps; the page size is _defaultLimit = 25 documents, so we are talking about hundreds of strings, not hundreds of thousands.
    • If interning were ever wanted it would belong in the driver's BSON decode, not in the view, and the claimed 35-50% memory saving has no measurement behind it.
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions