php / php/php-src

Single process memory model for opcache in ZTS

Abierto
#20,774 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Feature Status: Needs Triage
Lenguaje dominante
C
Estrellas
40.4k
Forks
8.1k
Merge medio
2 d 13 h
PR fusionados (30 d)
96

Descripción

Description

In ZTS, all requests run inside the same process, so there's no need for coordination between different processes.
This means that a non-SHM memory model could be used, and a lock file could be replaced by a regular mutex.

This would be beneficial for applications that run exclusively in ZTS and create userland threads, such as PocketMine-MP. PocketMine already uses ZTS and opcache CLI in most places, but it's currently unable to assume opcode caching is always available due to some platforms restricting access to certain lockfile features and SHM, such as Android.
PocketMine has a lot of users who insist on running servers on their mobile devices for some reason, so they'd stand to benefit :)

Since classes and op_arrays in general are non-thread-safe by default, threading extensions benefit a ton from Opcache since Opcache makes op_arrays and many other structures thread-safe by design, so they don't need to be copied. However, because Opcache uses features that are restricted on some platforms - features which are not necessary when running in ZTS mode and creating user threads - the likes of ext-pmmpthread still have to copy-paste large amounts of code from zend_persist.c to provide this functionality if Opcache is not available. If Opcache had a non-SHM memory model that didn't require lockfiles, mmap or any other fancy stuff, this would allow my threading extension to assume Opcache will always be available and caching code, which would potentially allow me to delete an insane amount of code and massively reduce the maintenance burden of the extension.

I don't know if there might be some advantages for ZTS in general (perhaps lower overhead?) but this doesn't seem like a hard change in any case as far as I can understand, so I thought I'd float the suggestion.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza rastreando el comportamiento actual de Opcache con respecto a SHM, lockfile y mmap junto con sus rutas ZTS; el issue no especifica archivos ni pruebas concretos. El trabajo estaría terminado cuando exista un modelo de memoria ZTS no basado en SHM que funcione mediante mutexes normales, sin el lockfile restringido ni las funciones de memoria compartida, con el comportamiento relevante de la plataforma verificado.

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

Evaluación

Stack tecnológico
c, php
Área
backend, 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
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.