Phase 2.5: Deferred activation — connect before enabling EXT_STMT#6
Merged
pronskiy merged 1 commit intophase2-observer-migrationfrom Mar 10, 2026
Merged
Conversation
At RINIT, when a debug trigger is present, attempt TCP connect to the client before enabling ZEND_COMPILE_EXTENDED_STMT. If no client is listening (ECONNREFUSED), keep observer_active=0 and skip EXT_STMT. This eliminates ~2.3x overhead in the triggered-no-client scenario (e.g. XDEBUG_SESSION=1 but no IDE listening). The extension now stays dormant, matching the untriggered performance (~10% observer floor). Two-stage connection approach: 1. RINIT: TCP connect only (xdebug_early_connect_to_client) 2. First function call: DBGp handshake on the pre-opened socket Also fixes RINIT trigger check to respect start_with_request=no and XDEBUG_IGNORE, matching xdebug_debug_init_if_requested_at_startup behavior. Benchmark (build server, PHP 8.6.0-dev): - Vanilla: ~0.55s - Loaded, no trigger: ~0.56s (~0%) - Loaded, triggered, no client (before): ~1.63s (~2.3x) - Loaded, triggered, no client (after): ~0.55s (~0%) Test results: 54 fail (same as Phase 2 baseline, zero regressions).
pronskiy
added a commit
that referenced
this pull request
Mar 11, 2026
Phase 2.5: Deferred activation — connect before enabling EXT_STMT
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.
Summary
At RINIT, when a debug trigger is present (e.g.
XDEBUG_SESSION=1), attempt TCP connect to the client before enablingZEND_COMPILE_EXTENDED_STMT. If no client is listening (ECONNREFUSED), keepobserver_active=0and skip EXT_STMT — the extension stays dormant.This eliminates ~2.3× overhead in the triggered-no-client scenario.
Approach: Two-stage connection
xdebug_early_connect_to_client()— no DBGp handshake (needsprogram_namefrom first op_array)xdebug_init_debugger()sees socket already open → skips connect → does DBGp handshakeAlso fixes RINIT trigger check to respect
start_with_request=noandXDEBUG_IGNORE, matchingxdebug_debug_init_if_requested_at_startup()behavior.Files changed
xdebug.c— RINIT early connect + EXT_STMT decisionsrc/debugger/com.c—xdebug_early_connect_to_client(), modifiedxdebug_init_debugger()to reuse pre-opened socketsrc/debugger/com.h— declarationsrc/debugger/debugger.c— initialize socket to -1Benchmarks (build server, PHP 8.6.0-dev)
Tests
54 failures — identical to Phase 2 baseline. Zero regressions.