Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-6548

Audit and document views and copies of bytes in BSON

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: BSON
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      As a Node.js engineer and user
      I want a clear idea of whether an API views or copies bytes
      So that I can write code accordingly

      User Experience

      • What is the desired/expected outcome for the user once this ticket is implemented?
        • At the very least documentation that calls out whether a view or copy is made
        • Copying when it makes sense to have a unique copy of data
        • Viewing when performance matters and copying can be accomplished externally

      Dependencies

      • BSON

      Risks/Unknowns

      • What could go wrong while implementing this change? (e.g., performance, inadvertent behavioral changes in adjacent functionality, existing tech debt, etc)
        • Caution should be taken to not regress performance if changes are being made
        • Semver also applies what normally would have been a copy should not become a view if it would break the assumption that bytes can be modified without side-effects on other views
      • Is there an opportunity for better cross-driver alignment or testing in this area?
        • Perhaps. It is a general concept that is in other languages. IIRC rust is capable of no copy views over BSON, but they can also control mutability in their declarations.
      • Is there an opportunity to improve existing documentation on this subject?
        • Yes that is the minimum goal of this ticket.

      Acceptance Criteria

      Implementation Requirements

      • Audit all:
        • views (Buffer.slice, subarray, Uint8Array given arraybuffer, etc.)
        • copies (Uint8Array.slice, Uint8Array given an iterable)
      • Add documentation clarifying which should be expected externally
      • Identify if any are problematic

      Testing Requirements

      • Any existing API should be tested to not change from view returning to copy returning or visa versa.

      Documentation Requirements

      • API Docs
      • Maybe manual docs if there's some global opinion/stance taken on views vs copies

      Follow Up Requirements

      • File a ticket to standardize behavior

            Assignee:
            Unassigned Unassigned
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: