Skip to content

fix: start a device's PowerShell without scanning every installed module - #2160

Merged
yansfil merged 11 commits into
mainfrom
fix/flaky-win-ps-start
Nov 6, 2026
Merged

yansfil merged 11 commits into
mainfrom
fix/flaky-win-ps-start

Conversation

@yansfil

@yansfil yansfil commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes with-hide/hide-private#580
Closes with-hide/hide-private#606
Closes with-hide/hide-private#607
Closes with-hide/hide-private#608
Closes with-hide/hide-private#609
Closes with-hide/hide-private#385
Closes with-hide/hide-private#386
Closes with-hide/hide-private#387
Closes with-hide/hide-private#240
Closes with-hide/hide-private#241

Summary

Windows에서 기기 연결과 hook 시험의 첫 PowerShell 시작이 가끔 60-90 s 동안 아무 말 없이 멈췄습니다.
원인은 PowerShell이 처음 쓰는 명령(Write-Output, New-Object, Add-Type, Test-Path)을 찾으려고 설치된 모듈 전체(러너에서 약 260개)를 읽는 데 있었습니다. 모듈 목록 캐시를 쓸 수 없으면 한 번에 12-38 s가 걸렸습니다.
이제 기기 시작 스크립트는 자동 로드를 끄고 쓰는 모듈 하나만 이름으로 불러옵니다. 캐시 없이도 1 s 안쪽입니다. 제한 시간은 그대로입니다.
첫 시작이 기한을 넘기면 실패 메시지가 그 프로세스의 pid, 쓴 CPU 시간 대 경과 시간, 받은 캐시 경로를 말합니다.

Review

  • 조심해서 볼 파일: hide-node/src/ssh/bootstrap.rs - 실제 기기에 가는 래퍼입니다. 모든 로그인 셸의 따옴표 안에 들어가므로 따옴표 없는 형태로 썼고, 그 검사(the_powershell_wrapper_holds_nothing_a_login_shell_reads_inside_quotes)는 그대로 통과합니다. 자동 로드가 꺼져 있어 스크립트가 앞으로 Utility 밖의 cmdlet을 쓰면 그 자리에서 이름과 함께 실패합니다.
  • 조심해서 볼 파일: hide-platform/src/process.rs - 새 사실 cpu_time(pid) 하나(macOS proc_pidinfo + 시간 기준, Linux /proc/<pid>/stat, Windows GetProcessTimes), 세 시스템 계약 시험 processor_time_counts_a_process_s_work_and_not_its_wait.
  • 판단해 주세요: PowerShell 로그인 셸(DefaultShell=powershell)은 래퍼 전에 exec를 찾습니다. 캐시가 차가우면 그 한 번은 여전히 전체 모듈을 읽습니다(측정 38 s). POSIX 첫 문장 앞에는 아무것도 둘 수 없어 이 PR에서 다루지 않았습니다.
  • 반복 중 드러난, 이 PR이 바꾸지 않은 시험: with-hide/hide-private#636, with-hide/hide-private#637, with-hide/hide-private#638. Cursor hook의 같은 종류 후속은 with-hide/hide-private#630에 적었습니다.
  • 이 그룹에서 뺀 이슈(다른 원인): with-hide/hide-private#523, Flaky test: A new tab in a Git checkout goes to the workspace Herdr binds to it, not the unbound one it was asked from #532, Add web Settings and workspace management (S5) #142.

Evidence

  • 확인한 것: 원인 측정(새 windows-latest 러너, 임시 workflow, run 42198773191, 42199406507): 캐시 없이 Write-Output 17.4 s, 다시 12.1 s, 넷 동시 32 s; 자동 로드 끄고 Utility import 후 Write-Output/New-Object/Add-Type 0.87 s.
  • 확인한 것: 20회 반복, retries 0, 임시 push workflow(리뷰 전에 지움). run 42201192406: 러너 5대 x 4회, bootstrap windows_tests 20/20 통과(10회는 빈 캐시). run 42203347592: 새 러너 20대 x 1회, bootstrap windows_tests 20/20(10대는 빈 캐시), hide-agent-hooks it의 Windows 레인 선택(hook_deadline|windows_hook_command|windows_scripts) 20/20 통과.
  • 확인한 것: 고친 두 줄을 지키는 Windows 시험: the_start_script_runs_under_an_empty_module_cache_without_building_one(빈 캐시에서 실제 스크립트가 캐시를 만들지 않음, import 줄)과 a_cmdlet_outside_the_wrappers_import_fails_by_name_and_starts_no_search(import 밖 cmdlet은 이름과 함께 바로 실패, 자동 로드 줄). PR의 run 42212770068에서 1.0 s, 3.6 s로 통과. 자동 로드 줄만 지운 임시 브랜치 run 42212808334에서는 두 번째 시험이 실패(Get-Item을 21 s 검색 끝에 찾음).
  • 확인한 것: cpu_time 계약 시험 macOS 로컬과 Windows 러너(run 42203347592)에서 통과. clippy, fmt 로컬 통과.
  • 확인하지 못한 것: 실패한 CI 회차에서 러너의 기본 캐시(C:\PSModuleAnalysisCachePath)가 왜 쓸 수 없었는지. 이제 캐시와 상관없이 기다리지 않으므로 고치는 데는 필요 없지만, 다시 멈추면 새 기한 보고가 이를 말합니다.
  • 확인하지 못한 것: hooks lib 시험 codex_daemon::tests::a_windows_codex_that_runs_node_answers_its_features가 새 러너 20대 중 8대에서 실패(Node 첫 시작이 5 s 제품 기한을 넘김, PowerShell 아님, 이 PR과 무관): with-hide/hide-private#638.
  • 확인하지 못한 것: Linux에서의 cpu_time 계약은 이 PR의 os contract 레인이 확인합니다.
  • 확인하지 못한 것: 실제 Windows 기기 연결(ssh)은 돌리지 않았습니다. 같은 스크립트를 실제 powershell.exe와 네 로그인 셸로 돌리는 bootstrap windows_tests로 확인했습니다.
Verification record

@yansfil
yansfil added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit cef65da Nov 6, 2026
66 checks passed
@yansfil
yansfil deleted the fix/flaky-win-ps-start branch November 6, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant