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

IndexCatalogEntry should expose NamespaceString to avoid type conversion/allocation in AbstractIndexAccessMethod

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.10
    • Component/s: None
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      Dev Tools 2019-04-08

      Description

      When inserting documents we create a new NamespaceString from a std::string const& causing a memory allocation. One allocation per document and index combination (also affecting insertMany). The NamespaceString is then used to query the ReplicationCoordinator where it does not need to store or keep the NamespaceString making the memory allocation above unnecessary.

      This especially affects performance in mobile/embedded where we most likely are single threaded.

      Partial callstack when running insertMany:

      mongoed.exe!mongo::AbstractIndexAccessMethod::shouldCheckIndexKeySize(mongo::OperationContext * opCtx) Line 150	C++
      mongoed.exe!mongo::AbstractIndexAccessMethod::insertKeys(mongo::OperationContext * opCtx, const std::set<mongo::BSONObj,mongo::BSONComparatorInterfaceBase<mongo::BSONObj>::LessThan,std::allocator<mongo::BSONObj> > & keys, const std::set<mongo::BSONObj,mongo::BSONComparatorInterfaceBase<mongo::BSONObj>::LessThan,std::allocator<mongo::BSONObj> > & multikeyMetadataKeys, const std::vector<std::set<unsigned __int64,std::less<unsigned __int64>,std::allocator<unsigned __int64> >,std::allocator<std::set<unsigned __int64,std::less<unsigned __int64>,std::allocator<unsigned __int64> > > > & multikeyPaths, const mongo::RecordId & loc, const mongo::InsertDeleteOptions & options, mongo::InsertResult * result) Line 201	C++
      mongoed.exe!mongo::AbstractIndexAccessMethod::insert(mongo::OperationContext * opCtx, const mongo::BSONObj & obj, const mongo::RecordId & loc, const mongo::InsertDeleteOptions & options, mongo::InsertResult * result) Line 191	C++
      mongoed.exe!mongo::IndexCatalogImpl::_indexFilteredRecords(mongo::OperationContext * opCtx, mongo::IndexCatalogEntry * index, const std::vector<mongo::BsonRecord,std::allocator<mongo::BsonRecord> > & bsonRecords, __int64 * keysInsertedOut) Line 1196	C++
      mongoed.exe!mongo::IndexCatalogImpl::_indexRecords(mongo::OperationContext * opCtx, mongo::IndexCatalogEntry * index, const std::vector<mongo::BsonRecord,std::allocator<mongo::BsonRecord> > & bsonRecords, __int64 * keysInsertedOut) Line 1216	C++
      mongoed.exe!mongo::IndexCatalogImpl::indexRecords(mongo::OperationContext * opCtx, const std::vector<mongo::BsonRecord,std::allocator<mongo::BsonRecord> > & bsonRecords, __int64 * keysInsertedOut) Line 1285	C++
      mongoed.exe!mongo::CollectionImpl::_insertDocuments(mongo::OperationContext * opCtx, std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<mongo::InsertStatement> > > begin, std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<mongo::InsertStatement> > > end, mongo::OpDebug * opDebug) Line 541	C++
      mongoed.exe!mongo::CollectionImpl::insertDocuments(mongo::OperationContext * opCtx, std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<mongo::InsertStatement> > > begin, std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<mongo::InsertStatement> > > end, mongo::OpDebug * opDebug, bool fromMigrate) Line 400	C++
      mongoed.exe!mongo::`anonymous namespace'::insertDocuments(mongo::OperationContext * opCtx, mongo::Collection * collection, std::_Vector_iterator<std::_Vector_val<std::_Simple_types<mongo::InsertStatement> > > begin, std::_Vector_iterator<std::_Vector_val<std::_Simple_types<mongo::InsertStatement> > > end, bool fromMigrate) Line 353	C++
      mongoed.exe!mongo::`anonymous namespace'::insertBatchAndHandleErrors(mongo::OperationContext * opCtx, const mongo::write_ops::Insert & wholeOp, std::vector<mongo::InsertStatement,std::allocator<mongo::InsertStatement> > & batch, mongo::`anonymous-namespace'::LastOpFixer * lastOpFixer, mongo::WriteResult * out, bool fromMigrate) Line 420	C++
      mongoed.exe!mongo::performInserts(mongo::OperationContext * opCtx, const mongo::write_ops::Insert & wholeOp, bool fromMigrate) Line 572	C++
      mongoed.exe!mongo::`anonymous namespace'::CmdInsert::Invocation::runImpl(mongo::OperationContext * opCtx, mongo::BSONObjBuilder & result) Line 300	C++
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              henrik.edin Henrik Edin
              Reporter:
              henrik.edin Henrik Edin
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: