Boost logo

Boost Users :

Subject: [Boost-users] [Multi-index container] Why insertions into my Multi-index container are so slow?
From: Angel Sunye (angelsunye_at_[hidden])
Date: 2008-09-04 08:58:04


Hi everyone,

I'm using a multi_index_container with 1 composite ordered_unique index
and 1 hashed unique index. It have passed the unit tests perfectly, but
when I have made the performance test, insertions into multi-index
container
went much slower than with a manual management. That grows exponentially
with the number of insertions:

  1000 insertions take 1.5 seconds, almost twice that without Multi-index
library
  10000 insertions take 160 seconds, thousands of times that without
Multi-index library

Below you can see my multi_index_container definition, and the insert calls
that i have used.

-----------------BEGIN CODE-----------------
  // TElementRec is a struct with its contructors //

  // Tags
  struct TMainIndexTag{};
  struct TKeyIndexTag{};

  typedef multi_index_container<
    TElementRec,
    indexed_by<
      ordered_unique<
        tag<TMainIndexTag>,
        composite_key<
          TElementRec,
          BOOST_MULTI_INDEX_MEMBER(TElementRec,PRIORITY_LEVEL,priority),
          BOOST_MULTI_INDEX_MEMBER(TElementRec,int,inputTimestamp),
          BOOST_MULTI_INDEX_MEMBER(TElementRec,TKey,key)
>
>,
      hashed_unique<
        tag<TKeyIndexTag>,
        BOOST_MULTI_INDEX_MEMBER(TElementRec,TKey,key)
>
>
> TElementsMIContainer;

  // Using...
  TElementsMIContainer elMIContainer;

  elMIContainer.insert( elMIContainer.template get<TMainIndexTag>().end(),
      TElementRec( priority, key, content, inputTimestamp, 0 ));

  elMIContainer.insert( TElementRec( priority, key, content, inputTimestamp,
0 ));
-----------------END CODE-----------------

Is this boost implementation correct?

Thanks a lot for your time

Angel Suñe Marti



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net