I don't see anything strange with your definitions... In order to try to elucidate what's
going on, I'd need some more information:

* Are you using the safe mode and/or the invariant-checking mode described at
 http://www.boost.org/libs/multi_index/doc/tutorial/debug.html ?

Perfect!!!... Just I had

#if !defined(NDEBUG)
#define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING
#define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE
#endif

and I haven't defined NDEBUG!!!

Now, time is much better than before, but still continues slow than manually.



* You say you're comparing against manual management: can you please explain
 what this manual management consists in?
 
I wanted to refer manual management as without using multi-index library. The code I used is as follows:

-----------------BEGIN CODE-----------------
// Record definition
struct TProcessRec {
   std::string text;
   u32         inputTimestamp;

   // Constructors...
};

enum PRIORITY_LEVEL
{
  PRIORITY_NULL,
  PRIORITY_LOW,
  PRIORITY_DEFAULT,
  PRIORITY_HIGH,
  PRIORITY_EXPRESS
};

// Key definition
struct QueueMsgKey {
  std::string msg_key;
  PRIORITY_LEVEL priority;
  // Constructors....
};

struct QueueMsgKeyLess {
    bool operator()(const QueueMsgKey k1, const QueueMsgKey k2) const 
    {  return k1.priority!=k2.priority ? k1.priority>k2.priority : k1.msg_key<k2.msg_key; }
};

struct MsgKeyLess {
    bool operator()(const  std::string k1, const  std::string k2) const 
    {  return k1<k2; }
};

// Container types definition
typedef std::map< QueueMsgKey, TProcessRec*, QueueMsgKeyLess > :: iterator TProcessListIterator;
typedef std::map< std::string, TProcessListIterator, MsgKeyLess >  :: iterator TRefListIterator;

// Class definition
class TOutProcessList
{
  private:
    TInProcessList process_list;
    TRefList ref_list;

  public:
    bool insert(const QueueMsgKey &qmsg_key, TProcessRec* const data)
    {
      TRefListIterator itr = ref_list.find( qmsg_key.msg_key );
      if ( itr == ref_list.end() ) {
        std::pair< TProcessListIterator, bool > result =  process_list.insert( std::make_pair( qmsg_key, data) );
        if(result.second == true) {
          ref_list[qmsg_key.msg_key] = result.first;
          return true;
        }
        else return false;
      }
      return false;
    };
};

// Testing manual form...
TOutProcessList elContainer;
for ( int i=0; i<10000; i++ ) {
  QueueMsgKey key( "A0000" + boost::lexical_cast<std::string>( i ) );
  elContainer.insert( key, new( "...", time(NULL) ));
}
// Here prints total time 1

// Testing with Multi-index library
TElementsMIContainer elMIContainer;
for ( int i=0; i<10000; i++ ) {
  elMIContainer.insert( elMIContainer.template get<TMainIndexTag>().end(), 
      TElementRec( priority, key, content, inputTimestamp, 0 ));
}
// Here prints total time 2

RESULT: time 2 > time 1

-----------------END CODE-----------------
 

* Are you building in release or debug mode? Any difference if you change this?
 
No. And I use the same program for comparing both forms (insertions with Multi-index and without).


* What's your environment (compiler, OS)?

 I'm using g++ 4.3.0 with Boost library 1.35.0 in Linux


* Are you able to isolate this odd behavior in a complete program that you can send
 to me so that I can reproduce the problem locally?
 
Copied before



Thanks a lot for your time
  
Angel Suņe Marti