Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost interprocess containers - performance issue
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2012-03-11 07:21:36


El 11/03/2012 1:00, Naveen Santhapuri escribió:
> Hello all,
>
> I am experimenting with Boost interprocess containers and like the
> ease of using them. I want to use these in place of the "linux shared
> memory+shared memory allocator + std containers". However, I am seeing
> some performance hit when using boost. I measured the times for vector
> access from shared memory. I define access as indexing into the vector
> (v[i]) (all times in milli seconds):
>
> Num elements Local heap | Boost ipc | Shmat()
> 100,000 0.23 0.39 0.27
> 1,000,000 2.3 3.85 2.7

What does Shmat mean? Are you putting a std::vector directly in a shared
memory segment?

Obviously if you put boost containers in shared memory you don't store
raw pointers (as every process can map the memory in a different
address, making raw pointers unusable). When using offset_ptr we have a
performance hit as we need to calculate the real address computing a
pointer arithmetic (this + stored offset). Apart from that, as
offset_ptr relies on undefined behaviour, the offset calculation must be
marked as non-inlineable in most compilers, increasing the performance
hit. I think it can be improved using some kind of compiler-specific
annotations or assembler, but I have no skills to do that nowadays.

Best,

Ion


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