boostorg / boostorg/interprocess
Extremly slow performance when constructing large arrays of basic type
- Dominant language
- C++
- Stars
- 185
- Forks
- 131
- PR merge metrics
- No merged PRs in 30d
Description
Hi, there are several Stack Overflow questions regarding performance issues when creating large arrays of basic types. For example, in this question (https://stackoverflow.com/questions/74609901/how-create-a-big-array-in-shared-memory-with-boostinterprocessmanaged-shard), the poster also experienced this problem. After profiling the code, I noticed that the root cause of the problem seems to be in this section (https://github.com/boostorg/interprocess/blob/55ad499dc4f9d1687dde25aeb23b0c6bffd44ed7/include/boost/interprocess/detail/named_proxy.hpp#L67-L76), which attempts to call the constructor for every element in the array.
Is it possible to write code to handle cases where the array is composed of basic types, and then initialize it using memset?
## To reproduce
```c++
#include
namespace bip = boost::interprocess;
int main() {
auto id_ = "shmTest";
size_t size_ = 2ul << 30;
bip::shared_memory_object::remove(id_);
bip::managed_shared_memory sm(bip::create_only, id_, size_ + 1024);
auto data_ = sm.construct("Data")[size_]('\0');
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.