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

Access of array fields is slow in SBE queries

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Major - P3
    • Resolution: Unresolved
    • None
    • None
    • None
    • ALL

    Description

      Summary: accessing an array field is ~15-30% slower in SBE compared to the classical engine.

       

      Create a collection that contains 10^6 documents like:

      { scalar: Random.randInt(10), array: [Random.randInt(10), Random.randInt(10), Random.randInt(10)],  }

      Let the collection have namespace of "sbe-perf.LS". From mongo shell run against the collection two benchmarks:
       

      {{benchRun({parallel: 1, seconds: 5, ops: [{op:"find", ns:"sbe-perf.LS", query: {scalar:7}, readCmd: true}]})}}
      

      results:
      "queryLatencyAverageMicros" : 434161.6666666667,
      "totalOps" : NumberLong(12),
      "totalOps/s" : 2.3032541141876615,
       

      benchRun({parallel: 1, seconds: 5, ops: [{op:"find", ns:"sbe-perf.LS", query: {array:7}, readCmd: true}]})
      

      results:
      "queryLatencyAverageMicros" : 872580.1666666666,
      "totalOps" : NumberLong(6),
      "totalOps/s" : 1.1460142483951503,

      The second benchRun is twice as slow. While we do expect the array access to be slower, the drop in SBE is much bigger than in the classic engine. For the classic engine the numbers are respectively:

      "queryLatencyAverageMicros" : 419583.25,
      "totalOps" : NumberLong(12),
      "totalOps/s" : 2.3832732351265875,

      and

      "queryLatencyAverageMicros" : 657760,
      "totalOps" : NumberLong(8),
      "totalOps/s" : 1.5202920024849174,

       

      The top 10 consumers of CPU in SBE

      Scalar
      +   15.99%  mongod              [.] mongo::sbe::vm::ByteCode::runInternal
      {{ +    8.10%  mongod              [.] __wt_txn_read_upd_list_internal}}
      {{ +    7.47%  mongod              [.] __wt_btcur_next_prefix}}
      {{ +    4.92%  mongod              [.] mongo::sbe::ProjectStage::getNext}}
      {{ +    4.08%  mongod              [.] mongo::WiredTigerRecordStoreCursorBase::next}}
      {{ +    3.70%  mongod              [.] __wt_cursor_get_valuev}}
      {{ +    3.42%  mongod              [.] mongo::sbe::vm::ByteCode::run}}
      {{ +    3.38%  mongod              [.] mongo::sbe::ScanStage::getNext}}
      {{ +    3.34%  mongod              [.] __unpack_read}}
      {{ +    3.03%  mongod              [.] __wt_cursor_get_keyv}}

       
      Array
      +   21.13%  mongod              [.] mongo::sbe::vm::ByteCode::runInternal
      +    5.97%  mongod              [.] mongo::sbe::vm::ByteCode::run
      +    4.49%  mongod              [.] mongo::sbe::ProjectStage::getNext
      +    4.44%  libc-2.27.so        [.] __strlen_avx2
      +    4.32%  mongod              [.] mongo::sbe::TraverseStage::traverse
      +    4.27%  mongod              [.] __wt_btcur_next_prefix
      +    3.93%  mongod              [.] __wt_txn_read_upd_list_internal
      +    2.40%  mongod              [.] mongo::sbe::vm::ByteCode::getField
      +    2.28%  mongod              [.] __wt_cursor_get_valuev
      +    2.02%  mongod              [.] mongo::WiredTigerRecordStoreCursorBase::next

      Flame graphs are attached.

       

      Attachments

        1. sbe-point-array.svg
          118 kB
        2. sbe-point-scalar.svg
          112 kB

        Issue Links

          Activity

            People

              backlog-query-execution Backlog - Query Execution
              irina.yatsenko@mongodb.com Irina Yatsenko
              Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated: