Visitar URL original
gh loads user32.dll on every start on Windows because of atotto/clipboard · Issue #14970 · cli/cli · GitHub
Skip to content

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

Open

Description

@azchohfi

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.

Activity

  1. cli-triage commented on Nov 6, 2026

    @cli-triage

    The latest release, 2.103.3, and current trunk both still use github.com/atotto/clipboard v0.1.4, while atotto/clipboard#74 remains open. That means the requested lazy DLL loading is not already available in gh. The report provides a focused Windows use case and measured startup impact across gh --version and an API call. This looks suitable to track as an enhancement. A future change should preserve clipboard behavior during authentication and compare startup results on Windows before and after the dependency change.

    Supporting reports

    Generated by issue triage.

  2. github-actions commented on Nov 6, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  3. jerdcms22-arch commented on Nov 7, 2026

    @jerdcms22-arch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions