boostorg / boostorg/interprocess
Extremly slow performance when constructing large arrays of basic type
- Vorherrschende Sprache
- C++
- Sterne
- 185
- Forks
- 131
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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');
}
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginnen Sie mit include/boost/interprocess/detail/named_proxy.hpp im Bereich der Zeilen 67–76 und kompilieren Sie den bereitgestellten managed_shared_memory-Reproducer. Vergleichen Sie die Konstruktionszeit für das große char-Array und ermitteln und dokumentieren Sie anschließend eine geeignete Abschlussprüfung für die Initialisierung eines Arrays von Basistypen, ohne das Verhalten für andere Elementtypen zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp
- Bereich
- operating-systems, performance
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 32/100