php / php/php-src

Single process memory model for opcache in ZTS

Offen
#20,774 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Feature Status: Needs Triage
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.1k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, das aktuelle Verhalten von Opcache in Bezug auf SHM, Lockfile und mmap zusammen mit seinen ZTS-Pfaden nachzuverfolgen; das Issue nennt keine spezifischen Dateien oder Tests. Erledigt wäre die Implementierung eines funktionierenden Nicht-SHM-ZTS-Speichermodells mit regulären Mutexes, ohne das eingeschränkte Lockfile oder die Shared-Memory-Funktionen, wobei das relevante Plattformverhalten verifiziert ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, php
Bereich
backend, operating-systems
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.