Performance optimisations: split debugger init into two parts and defer the heavy one#13
Closed
Performance optimisations: split debugger init into two parts and defer the heavy one#13
Conversation
Split xdebug_debugger_rinit() into two phases: - rinit_early(): minimal setup (IDE key, no_exec, context init) - rinit(): heavy work (opcache disable, breakable_lines_map alloc) The full rinit() now only runs when an IDE client actually connects. When no IDE is listening (the common case with triggers), we skip: - breakable_lines_map hash allocation (2048 buckets) - xdebug_disable_opcache_optimizer() INI modifications - related string allocations Mid-request connections (xdebug_break, start_upon_error) lazily call xdebug_debugger_rinit() via xdebug_init_debugger(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restructure RINIT to move the trigger/connection check before heavy allocations. When no IDE is listening (the common case), the extension now uses dormant init paths that skip: - xdebug_library_rinit: diagnosis_buffer, headers list, trait_location_map (256-bucket hash), log file open, path mapping - xdebug_base_rinit: fiber_stacks (64-bucket hash), stack vector, filters linked list, closure serializer, control socket, error/exception handler overrides Added NULL guards to all cleanup paths and the fiber switch observer to handle the dormant state safely. This eliminates all per-request heap allocations when no debugger will connect, reducing overhead for short-lived PHP-FPM requests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract xdebug_library_rinit_log() to open diagnosis_buffer and log file early in RINIT, before the trigger/connection check. This ensures log messages from trigger evaluation (XDEBUG_IGNORE, trigger mismatch) and connection attempts are captured even on the dormant path. Fixes tests: bug01978, bug02348, start_ignore_yes_env, start_with_request_trigger_match-009, trigger_match-010. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
xdebug_debugger_rinit()intorinit_early()(IDE key, context) andrinit()(opcache disable, breakable_lines_map). Full rinit only runs after successful IDE connection.xdebug_library_rinit_dormant,xdebug_base_rinit_dormant) that skip fiber_stacks, stack vector, trait_location_map, headers, diagnosis_buffer, filters, error handler overrides. Added NULL guards to all cleanup paths.