
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