perf(pam launch): cache TunnelDAG across the launch flow#1981
Merged
idimov-keeper merged 1 commit intoreleasefrom Apr 22, 2026
Merged
perf(pam launch): cache TunnelDAG across the launch flow#1981idimov-keeper merged 1 commit intoreleasefrom
idimov-keeper merged 1 commit intoreleasefrom
Conversation
Previously ``_get_launch_credential_uid`` was called three times per launch — once in ``launch.execute`` and twice inside ``extract_terminal_settings`` — and each call built a fresh ``TunnelDAG`` (2-3 HTTP round-trips each). ``find_gateway`` also re-resolved the config UID via ``get_config_uid_from_record``. Build the TunnelDAG once in ``execute()`` and thread it through: - ``_get_launch_credential_uid(params, record_uid, tdag=...)`` reuses the caller's DAG when provided. - ``find_gateway(params, record_uid, tdag=...)`` reads ``config_uid`` from ``tdag.record.record_uid`` and uses the new ``_gateway_uid_from_config`` helper to skip the redundant ``get_leafs`` roundtrip. - ``extract_terminal_settings(..., dag_linked_uid=...)`` takes a pre-resolved value via a ``_DAG_UID_UNSET`` sentinel (``None`` is a valid resolved result) and drops both inline DAG lookups. Add a ``PamConnectTiming`` framework (new ``connect_timing.py``) gated by ``PAM_CONNECT_TIMING=1`` and instrument the full launch: - ``pam-launch:execute`` — pre-phase checkpoints through gateway resolution (previously invisible). - ``pam-launch:terminal_connection`` / ``pam-launch:webrtc-tunnel`` — existing phase boundaries around tunnel open. - ``pam-launch:cli_session`` — checkpoints through guac ready. - ``pam-launch:total`` — grand-total wall clock from command entry to ``input_handler.start()``. Verified against QA: grand total ``ready_for_prompt`` drops from ~17.0s to ~12.4s (~4.6s saved). A single ``Found launch credential via DAG`` log line per launch (was three). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
sk-keeper
pushed a commit
that referenced
this pull request
Apr 24, 2026
Previously ``_get_launch_credential_uid`` was called three times per launch — once in ``launch.execute`` and twice inside ``extract_terminal_settings`` — and each call built a fresh ``TunnelDAG`` (2-3 HTTP round-trips each). ``find_gateway`` also re-resolved the config UID via ``get_config_uid_from_record``. Build the TunnelDAG once in ``execute()`` and thread it through: - ``_get_launch_credential_uid(params, record_uid, tdag=...)`` reuses the caller's DAG when provided. - ``find_gateway(params, record_uid, tdag=...)`` reads ``config_uid`` from ``tdag.record.record_uid`` and uses the new ``_gateway_uid_from_config`` helper to skip the redundant ``get_leafs`` roundtrip. - ``extract_terminal_settings(..., dag_linked_uid=...)`` takes a pre-resolved value via a ``_DAG_UID_UNSET`` sentinel (``None`` is a valid resolved result) and drops both inline DAG lookups. Add a ``PamConnectTiming`` framework (new ``connect_timing.py``) gated by ``PAM_CONNECT_TIMING=1`` and instrument the full launch: - ``pam-launch:execute`` — pre-phase checkpoints through gateway resolution (previously invisible). - ``pam-launch:terminal_connection`` / ``pam-launch:webrtc-tunnel`` — existing phase boundaries around tunnel open. - ``pam-launch:cli_session`` — checkpoints through guac ready. - ``pam-launch:total`` — grand-total wall clock from command entry to ``input_handler.start()``. Verified against QA: grand total ``ready_for_prompt`` drops from ~17.0s to ~12.4s (~4.6s saved). A single ``Found launch credential via DAG`` log line per launch (was three). Co-authored-by: Claude Opus 4.7 <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.
Previously
_get_launch_credential_uidwas called three times per launch — once inlaunch.executeand twice insideextract_terminal_settings— and each call built a freshTunnelDAG(2-3 HTTP round-trips each).find_gatewayalso re-resolved the config UID viaget_config_uid_from_record.Build the TunnelDAG once in
execute()and thread it through:_get_launch_credential_uid(params, record_uid, tdag=...)reuses the caller's DAG when provided.find_gateway(params, record_uid, tdag=...)readsconfig_uidfromtdag.record.record_uidand uses the new_gateway_uid_from_confighelper to skip the redundantget_leafsroundtrip.extract_terminal_settings(..., dag_linked_uid=...)takes a pre-resolved value via a_DAG_UID_UNSETsentinel (Noneis a valid resolved result) and drops both inline DAG lookups.Add a
PamConnectTimingframework (newconnect_timing.py) gated byPAM_CONNECT_TIMING=1and instrument the full launch:pam-launch:execute— pre-phase checkpoints through gateway resolution (previously invisible).pam-launch:terminal_connection/pam-launch:webrtc-tunnel— existing phase boundaries around tunnel open.pam-launch:cli_session— checkpoints through guac ready.pam-launch:total— grand-total wall clock from command entry toinput_handler.start().Verified against QA: grand total
ready_for_promptdrops from ~17.0s to ~12.4s (~4.6s saved). A singleFound launch credential via DAGlog line per launch (was three).