Conversation
|
✨ Fix all issues with BitsAI or with Cursor
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3670 +/- ##
==========================================
- Coverage 62.20% 62.13% -0.07%
==========================================
Files 141 141
Lines 13352 13352
Branches 1746 1746
==========================================
- Hits 8305 8296 -9
- Misses 4256 4263 +7
- Partials 791 793 +2 see 4 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Benchmarks [ tracer ]Benchmark execution time: 2026-02-28 00:01:12 Comparing candidate commit 4630694 in PR branch Found 2 performance improvements and 1 performance regressions! Performance is the same for 188 metrics, 3 unstable metrics. scenario:MessagePackSerializationBench/benchMessagePackSerialization
scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache
scenario:SamplingRuleMatchingBench/benchRegexMatching1
|
5a292ea to
e26db1d
Compare
| (void)in_request; | ||
| #endif | ||
|
|
||
| if (in_request) { |
There was a problem hiding this comment.
We only need it for FPM, right? So let's add a sapi_module check here?
Saving some minor time on CLI scripts.
There was a problem hiding this comment.
I'm not sure what litespeed does, and IIRC we did have a customer using it. How about a not-CLI SAPI check instead? That way web SAPIs stay consistent, but it's skipped on CLI where it's unnecessary.
There was a problem hiding this comment.
I think it's reasonably clearer now. Patch is smaller, at least xD
| if (!cached->ptr) return false; | ||
| if (cached->len >= buf.len) return false; | ||
|
|
||
| memcpy(buf.ptr, cached->ptr, cached->len + 1); |
There was a problem hiding this comment.
There's not really an intrinsic need to copy. The copying in zai_getenv_ex is also unnecessary, but here we very clearly don't need it (but yeah, you'll have to duplicate branches then).
I'd personally return a simple zai_str instead of zai_env_buffer.
| typedef struct { | ||
| // ptr == NULL means env var was unset at MINIT. | ||
| // ptr != NULL with len == 0 means env var was set to an empty string. | ||
| char *ptr; | ||
| size_t len; | ||
| } zai_config_cached_env_value; | ||
|
|
||
| static zai_config_cached_env_value zai_config_cached_env_values[ZAI_CONFIG_ENTRIES_COUNT_MAX][ZAI_CONFIG_NAMES_COUNT_MAX]; |
There was a problem hiding this comment.
| typedef struct { | |
| // ptr == NULL means env var was unset at MINIT. | |
| // ptr != NULL with len == 0 means env var was set to an empty string. | |
| char *ptr; | |
| size_t len; | |
| } zai_config_cached_env_value; | |
| static zai_config_cached_env_value zai_config_cached_env_values[ZAI_CONFIG_ENTRIES_COUNT_MAX][ZAI_CONFIG_NAMES_COUNT_MAX]; | |
| static zai_string zai_config_cached_env_values[ZAI_CONFIG_ENTRIES_COUNT_MAX][ZAI_CONFIG_NAMES_COUNT_MAX]; |
Simply?
There was a problem hiding this comment.
zai_string isn't supposed to have a null pointer, right? IIRC that's why I did this. This distinguishes between unset and null. But there is a zai_option_str, and I think using a zai_option_str except actually owning it is better than putting null into zai_string. So I'll experiment with that.
e26db1d to
58b7933
Compare
In rinit, calling system getenv when a SAPI env var isn't found is slow enough it shows up in profiles. glibc's getenv does a linear scan on the environ and does strncmp on the members, so we can definitely do better. We save it in minit so it's available for SYSTEM_INI variables and again on the first request. This is also arguably more correct: system environment variables map to a system INI setting, which shouldn't change at runtime.
58b7933 to
091c262
Compare
Background
In request initialization aka rinit/activate, calling the system
getenvwhen a SAPI env var isn't found is slow enough it shows up in profiles:Note that glibc's
getenvdoes a linear scan on the environ and doesstrncmpon the members, so we can definitely do better.Description
Caches libc's
getenvin minit and again in first rinit. Note that php-fpm'senvdirective actually changes the system env var, it doesn't include it in the fastcgi environment. This change is also more correct: system environment variables map to a system INI setting, which shouldn't change at runtime, so if they do, we shouldn't really respect it.Here's an example diff from the profiling comparison view:
Reviewer checklist