I am newbee to IPC. The Writer process writes the data into shared memory, Many reader processes reads the data. The data to be written have a unique identifier, has to be be indexed by unique key for the faster access( like STL::map or hashmap for lookup). Also data is a varible length record ( XML ) ( average lenght is 200-250 bytes ). OS is solaris 10 (i86pc) on Intel Xeon Quad Core Server.
Total data size is more than 200G. But we will be keeping only latest data in the shared memory. Historical data resides in file. shared memory size would be around 4G~6G.
No external library avaiable like Boost::interprocess
I have couple of questions, may be many
- Which is more efficient : shared_memory or mmap (Memory Mapped Files)
- How to build indexes for variable length record. [i have no idea, May be some hashing?].
- Would this be neat if XML is converted into fixed size structure ( Trade off - size of the structure will be huge, nearly 300+ possible fields )
- Can we place any STL in the shared_memory by providing custom allocator .?
- Is it possible to implement without semaphores (lockless implementation using CAS ).
Thanks
How about this.
|--------------------------|
| start_id | end_id | -> range of msg id present in the segment
|--------------------------|
| id1 | start_mem | length | ->
|--------------------------| ->
| id2 | start_mem | length | -> table of index for the actual data
|--------------------------| ->
| id3 | start_mem | length | ->
|--------------------------| ->
| id4 | start_mem | length | ->
|--------------------------| ->
| |
| |
| |
| data segment |
| varibale length |
| xml are stored |
| |
| |
|--------------------------|
When the new data arrives and segment is full. oldest data is erased in a circular fashion. There can be a possibility of more than 1 record need to erased.
Since lockless ( lock-free ) implementations are hard to design and we might end up in chaos, before going for lock-free solution you should consider following aspects and alternatives: