Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5553

Reduce decoding overhead when checking in InternalStreamConnection if a command is in SECURITY_SENSITIVE_COMMANDS

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Performance
    • None
    • Java Drivers

      When InternalStreamConnection checks whether the command contained in bsonOutput (the encoded message) is in SECURITY_SENSITIVE_COMMANDS, it calls message.getCommandDocument: https://github.com/mongodb/mongo-java-driver/blob/a461dbabc338fefb8e003c1b30112174a3e99791/driver-core/src/main/com/mongodb/internal/connection/InternalStreamConnection.java#L481. While this method tries to avoid actually decoding bytes as much as possible, sometimes that is unavoidable (see https://github.com/mongodb/mongo-java-driver/pull/1456#discussion_r1691968763).

      We can optimize these checks by introducing quite a trivial method that only decodes the first BSON key from bsonOutput, taking into account that BSON starts at message.getEncodingMetadata().getFirstDocumentPosition().

            Assignee:
            Unassigned Unassigned
            Reporter:
            valentin.kovalenko@mongodb.com Valentin Kavalenka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: