Skip to content

Avoid cloning the entire document type for each reservation #6305

Backlog

Description

@thepastaclaw

PastaClaw flagged this while reviewing #5749, where it was deferred to a follow-up instead of being fixed in that pull request. This issue tracks the follow-up.

Avoid cloning the entire document type for each reservation (suggestion)

Where: packages/rs-dpp/src/data_contract/document_type/mod.rs:466-467 at 86bbb70a1a2e:

let mut document_type = self.to_owned_document_type();
match &mut document_type {

with_only_indexes is called during every indexed-random insertion, but to_owned_document_type deep-clones DocumentTypeV2 before filtering it. Its derived Clone copies the owned schema, both property maps, constraints, indexes, and the original index structure, which keep_only_indexes then replaces. Pricing one small random index therefore allocates in proportion to the whole type definition for each document. Build a filtered index representation that borrows unchanged metadata, or cache the projection by contract version and document type, instead of repeating the deep clone per create. Registration is currently inactive, so this is a nonblocking hot-path improvement before activation.

Origin

Activity

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