boostorg / boostorg/interprocess

How do i madvise the mapped_region for managed_shared_memory?

Abierto
#268 4 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C++
Estrellas
185
Forks
131
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

For performance reasons we want to preallocate memory in the shared memory by calling madvise(MADV_POPULATE_WRITE). This generally has significant benefit in performance during the bootstrap phase as compared to allocate memory when the memory is accessed. However there are 2 reasons why we cannot do this today:

1. First the managed_shared_memory does not expose the public apis of managed_open_or_create_impl so we are unable to access to api get_mapped_region
2. Even we would have access to the mapped_region, the advise api supports only selected options (enum advice_types) and MADV_POPULATE_WRITE is not part of it.

Do you plan to support this?

I guess the only viable alternative is I separately create the shared_memory and madvise it before initializing using boost's shared_memory something like this:

fd= shm_open("BoostShmem", O_CREATE)
ptr = mmap64(
NULL, fileSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
madvise(ptr, fileSize, MADV_POPULATE_WRITE);
boost::interprocess::managed_shared_memory shared_memory(boost::interprocess::create_only,
"BoostShmem", fileSize);

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Comienza leyendo managed_shared_memory y managed_open_or_create_impl, centrándote en cómo get_mapped_region llega a mapped_region y en cómo se gestionan advice_types. Determina la compatibilidad de API y de plataforma necesaria para MADV_POPULATE_WRITE; el trabajo estará terminado cuando managed shared memory pueda exponer la mapped region y aplicar este aviso mediante la interfaz pública.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
cpp
Área
operating-systems
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
28/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.