gh loads user32.dll on every start on Windows because of atotto/clipboard

Đang mở Phù hợp với người mới
#14,970 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
66/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
cli, performance

Hướng nghiên cứu

Bắt đầu với dependency internal/authflow tới github.com/atotto/clipboard và kiểm tra clipboard_windows.go trong dependency v0.1.4 được báo cáo. Kiểm tra xem atotto/clipboard#74 đã được phát hành chưa, sau đó đánh giá việc cập nhật dependency hoặc phương án dùng fork tạm thời; hoàn thành nghĩa là Windows không còn tải eager các DLL không được sử dụng khi khởi động, trong khi việc đọc clipboard vẫn hoạt động. Issue đề cập đến một chương trình kiểm thử hành vi clipboard nhưng không nêu tên tệp test hay benchmark nào trong repository.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement
Describe the feature or problem you’d like to solve

On Windows every gh process loads user32.dll, and with it win32u, gdi32, gdi32full and imm32, including gh --version and gh api. gh does not use them outside of copying the one-time code during login. They are loaded by github.com/atotto/clipboard v0.1.4 (imported by internal/authflow): its clipboard_windows.go calls syscall.MustLoadDLL("user32") and MustFindProc at package initialization, so the DLL is loaded before main runs.

atotto/clipboard#74 (open) changes these to lazy windows.NewLazySystemDLL lookups.

Measurements: gh 2.103.3 built twice with Go 1.27.3 and the release ldflags, once as is and once with replace github.com/atotto/clipboard => <v0.1.4 + #74>. Windows 11, interleaved runs, median of paired differences with 95% confidence interval, two separate runs:

images loaded gh --version gh api /user (local test server)
as is 16
with #74 10 -4.1 ms (2.7 to 5.4); -7.5 ms (5.4 to 11.4) -1.6 ms (-1.1 to 4.2); -3.5 ms (0.4 to 5.2)

The self-built gh matches the release binary. Reading the clipboard still works with the lazy version (checked in a small test program).

Proposed solution

Either bump atotto/clipboard once #74 is released, or point a replace at a fork with #74 until then. This saves a few ms on every gh call on Windows, which adds up for scripts and agents that call gh many times. Happy to open a PR if this gets the help wanted label.

Additional context

gh version 2.103.3 (2026-10-26), Windows 11 x64.

Ngôn ngữ chính
Go
Star
47.4k
Fork
9.5k
Merge trung bình
18 giờ 34 phút
Pull request đã merge (30 ngày)
70

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cli/cli

Tất cả issue của cli/cli

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.