Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-80295

Refactor command reply processing path to reduce BSON parsing passes

    • Service Arch
    • Fully Compatible
    • Service Arch 2023-09-18, Service Arch 2023-10-02, Service Arch 2023-10-16, Service Arch 2024-04-01

      There are several calls to BSONObj::getField that are made by functions called by RunCommandImpl::_epilogue. These are chiefly CommandHelpers::extractOrAppendOK and mongo::getStatusFromCommandResult. These command parsers can be consolidated with the help of an IDL generated parser to reduce the amount of parsing of the BSON reply.

      Also, CommandHelpers::checkForInternalError can be made debug only to avoid yet another pass over the reply.

      Example of the reply fields that can be consolidated in an IDL definition:

        CommonReplyArgs:
            description: TODO
            strict: false
            unsafe_dangerous_disable_extra_field_duplicate_checks: true
            fields:
              ok:
                type: safeBool
                optional: true
              code:
                type: safeInt
                optional: true
              errmsg:
                type: string
                optional: true
              $err:
                cpp_name: dollarErr
                type: string
                optional: true
              writeConcernError:
                type: object
                optional: true
      

      Note: There may be opportunity to align with the reply fields defined in src/mongo/idl/generic_argument.idl. On the other hand, a more narrow parser for this error handling will be better then a wider parser handling all generic reply fields.

      POC: https://github.com/markbenvenuto/mongo/tree/tiger_perf_bson

            Assignee:
            alex.li@mongodb.com Alex Li
            Reporter:
            mark.benvenuto@mongodb.com Mark Benvenuto
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: