Merged
Conversation
# Conflicts: # cgi.go
# Conflicts: # cgi.go # frankenphp.c # phpmainthread.go
# Conflicts: # frankenphp.c # phpmainthread.go
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors how CGI/$_SERVER string keys are managed by moving hard-coded zend_string keys into a C-side interned-strings struct, reducing Go-side map lookups/allocations and enabling more efficient $_SERVER sizing during registration.
Changes:
- Introduces C-side interned string registry (
frankenphp_strings) and afrankenphp_server_varsstruct to bulk-register known$_SERVERvariables with pre-sized hashtable capacity. - Simplifies Go-side CGI/server-variable registration to rely on C-side known keys, keeping only the common-header cache map in Go.
- Minor header handling refactor in Go to pass
sapi_header_structdirectly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
phpmainthread.go |
Moves common header zend_string cache to a package-global map and initializes it once. |
frankenphp.h |
Defines frankenphp_server_vars and frankenphp_strings interned-string registry; updates exported APIs. |
frankenphp.go |
Adjusts header parsing helper to accept sapi_header_struct. |
frankenphp.c |
Implements interned-string initialization, server var bulk registration, and updates request variable registration flow. |
env.go |
Captures OS env count for $_SERVER pre-sizing; switches to newPersistentZendString. |
cgi.go |
Reworks known CGI var registration to use C-side interned keys/values; adds tlsProtocol and helper wrappers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dunglas
approved these changes
Mar 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR does a bit of cleanup with how Cgi strings are registered by moving the
zend_stringkeys to a struct on the C side. This also has some performance benefits, mainly by not having to do map access and correctly sizing the$_SERVERarray.Server registration goes from around 5.5% of request time to around 3.5%.
Draft as waiting for #2058 first.