Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sparse Maps rather than dense sources arrays in mergeType code. #3069

Merged

Commits on Jul 8, 2024

  1. Configuration menu
    Copy the full SHA
    8ee7b95 View commit details
    Browse the repository at this point in the history
  2. Use sparse Map instead of large sources arrays during merge.

    The goal of this commit is to switch from using a dense array for the
    various 'sources' passed around in mergeType code, to using a Map
    instead. These Map structures have the potential to omit many elements
    corresponding to irrelevant subgraphs, becoming sparser than an array,
    but this commit preserves the dense array-like behavior, for now.
    benjamn authored and sachindshinde committed Jul 8, 2024
    Configuration menu
    Copy the full SHA
    60ba870 View commit details
    Browse the repository at this point in the history
  3. Do more work in addFieldsShallow method.

    Since we already loop over all input sources to add shallow versions of
    fields to the dest object in addFieldsShallow, we can return a
    representation of what was added to be used later in mergeObject,
    mergeInterface, and mergeInput, yielding a speedup.
    
    The source of the speedup is the use of sparse Sources maps, so not all
    subgraphs need to have an entry in Sources, though some subgraphs still
    do have (intentionally) undefined entries, indicating the subgraph does
    not contribute a particular field, but might matter for validation of
    the field.
    
    I'm aware JavaScript also supports "sparse arrays" which are Array
    objects with "holes" in them (missing elements, not just undefined), but
    not all operations (such as sparseArray.entries()) skip the holes, so it
    seemed better/safer to use an explicitly sparse data structure like Map.
    benjamn authored and sachindshinde committed Jul 8, 2024
    Configuration menu
    Copy the full SHA
    4b04118 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    eca8ce6 View commit details
    Browse the repository at this point in the history
  5. Add changeset entry

    sachindshinde committed Jul 8, 2024
    Configuration menu
    Copy the full SHA
    f5f6a79 View commit details
    Browse the repository at this point in the history