-
Notifications
You must be signed in to change notification settings - Fork 420
perf: move sandboxed environment to the C side #2058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AlliBalliBaba
wants to merge
38
commits into
main
Choose a base branch
from
refactor/cleanup-env
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
* removes backoff. * Adjusts comment. * Suggestions by @dunglas * Removes 'max_consecutive_failures' * Removes 'max_consecutive_failures' * Adjusts warning. * Disables the logger in tests. * Revert "Adjusts warning." This reverts commit e93a6a9. * Revert "Removes 'max_consecutive_failures'" This reverts commit ba28ea0. * Revert "Removes 'max_consecutive_failures'" This reverts commit 32e649c. * Only fails on max failures again. * Restores failure timings.
# Conflicts: # phpmainthread_test.go
# Conflicts: # phpthread.go # threadworker.go
# Conflicts: # phpthread.go # threadinactive.go # threadregular.go # threadworker.go # worker.go
# Conflicts: # phpmainthread_test.go # threadregular.go
# Conflicts: # env.go # frankenphp.c # phpmainthread.go # phpthread.go # threadregular.go
# Conflicts: # env.go # frankenphp.c # phpmainthread.go # phpthread.go # threadregular.go
AlliBalliBaba
commented
Dec 13, 2025
Comment on lines
+317
to
+330
| // cut the string at the first '=' | ||
| char *eq_pos = memchr(setting, '=', setting_len); | ||
| bool put_env_success = true; | ||
| if (eq_pos != NULL) { | ||
| size_t name_len = eq_pos - setting; | ||
| size_t value_len = | ||
| (setting_len > name_len + 1) ? (setting_len - name_len - 1) : 0; | ||
| put_env_success = | ||
| go_putenv(setting, (int)name_len, eq_pos + 1, (int)value_len); | ||
| if (put_env_success) { | ||
| zval val = {0}; | ||
| ZVAL_STRINGL(&val, eq_pos + 1, value_len); | ||
| zend_hash_str_update(sandboxed_env, setting, name_len, &val); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important to note that doing string cutting like this is binary safe, in contrast to the php-src implementation (null bytes will be forwarded and rejected by go's putenv)
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 uses
zend_array_dupto simplify the environment sandboxing logic. It removes the CGO overhead from$_ENVand$_SERVERregistration in regular threads and saves some memory on many threads. (wip)