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 68.80% 68.73% -0.08%
==========================================
Files 166 166
Lines 19030 19030
Branches 1797 1797
==========================================
- Hits 13094 13080 -14
- Misses 5122 5135 +13
- Partials 814 815 +1
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Benchmarks [ tracer ]Benchmark execution time: 2026-03-19 20:02:07 Comparing candidate commit 5970886 in PR branch Found 5 performance improvements and 2 performance regressions! Performance is the same for 185 metrics, 2 unstable metrics. scenario:BM_TeaSapiSpindown
scenario:EmptyFileBench/benchEmptyFileDdprof
scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache
scenario:SamplingRuleMatchingBench/benchRegexMatching2
scenario:SymfonyBench/benchSymfonyBaseline
scenario:SymfonyBench/benchSymfonyDdprof-opcache
scenario:SymfonyBench/benchSymfonyOverhead
|
5a292ea to
e26db1d
Compare
58b7933 to
091c262
Compare
54de6fc to
41fc47c
Compare
|
Good job on refactoring the zai_env stuff, that's much more readable now. |
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.
Replace zai_getenv_ex/zai_getenv with two focused functions: - zai_sapi_getenv: borrows value from the SAPI environment - zai_sys_getenv: borrows value from the process environment Both return zai_option_str instead of writing into a caller-supplied buffer, eliminating the ZAI_ENV_BUFFER_* error codes and the scratch buffer indirection throughout callers. Update config, config_ini, and otel_config to use the new API. Rename zai_config_get_cached_env_value to zai_config_sys_getenv_cached to return zai_option_str directly. Add ZAI_OPTION_STRL macro and zai_option_str_eq helper to string.h. Remove now-obsolete error.cc env tests.
- Remove !env_to_ini_name guard from zai_config_ini_rinit so SAPI env vars (e.g. Apache SetEnv) are always consulted at RINIT, not only when env_to_ini_name is NULL. This restores ini->modified being set from env vars, which the Rust RC client relies on to detect user-set values before applying dynamic config overrides. - Add SAPI env check to zai_config_find_and_set_value at first RINIT so values are visible before zai_config_ini_rinit runs. Code such as the signal handler setup for DD_TRACE_HEALTH_METRICS_ENABLED (Apache SetEnv) reads decoded config between first_time_rinit and zai_config_ini_rinit and requires SAPI env to be present at that point. - Remove erroneous manual zai_config_first_time_rinit(true) call in the perdir/multi-consumer INI test; REQUEST_BEGIN already triggers it through the extension RINIT handler. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
a12cb93 to
faa345e
Compare
bwoebi
left a comment
There was a problem hiding this comment.
Looks good to me, nice job Levi :-)
…dd-update * 'master' of github.com:DataDog/dd-trace-php: feat(sidecar): add thread mode as fallback connection for restricted environments (#3573) Migrate deprecated GitLab runner tags (#3715) Adds process tags to remote config payload (#3658) perf(config): cache sys getenv (#3670) Fixes the tag name for process tags (#3709) Fix debugger ephemerals handling (#3685) Fix #3651: Prevent crash during shutdown in Frankenphp (#3662) Add dynamic instrumentation and exception replay to startup logging (#3667) chore: bump bytes crate from 1.9.0 to 1.11.1 to address CVE-2026-25541 (#3669) Merge pull request #3701 from DataDog/brian.marks/add-ksr-tag ci: fix Windows job flakiness caused by dirty workspace (#3694) Fixup CI owner association (#3704) Add Rust rewrite of the AppSec helper alongside the C++ implementation Remove debug instruction Fix script order debug Fix exploration logic chore(ci): add final_status property on junit XML [APMSP-2610] Fix DD_TRACE_SYMFONY_HTTP_ROUTE=false Optimize Symfony http.route caching with path map approach
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, so that's why we have to grab it again on first rinit. 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.We also make another optimization as part of this: we borrow memory from the config when possible for the decoder. Examples include otel normalization when the result is a static string like "0" or "1", as well as when using system environment variables.
Parts of zai config had to be refactored. The internals were very brittle to changes. This PR refines the tests and hopefully improves documentation as well so that it's a bit less so.
Overall, we shaved off roughly 40-50% of the time spent in
zai_config_rinit. Here's an example diff from the profiling comparison view:Note that you can see
sapi_getenvin the flamegraph now where you couldn't before. However, we still come out ahead.Reviewer checklist