Skip to content

nsgo check: -target runs repeat the host vet and nothing bounds parallelism, so splitting a slow check saturates the machine #652

Closed

Description

@houko

Context

go tool nsgo check -target all vets 15 targets one after another (goAndXcodeTargets, cmd/nsgo/build.go:316 on main at 7ec1e19), and in NSGo's own repository each target is vetted twice (./..., then ./internal/platform/... with nsgotest, cmd/nsgo/check.go:104-108). With the host vet and the two dev client vets that check runs first (check.go:36-56), one run is about 33 go vet passes, and since every GOOS/GOARCH has its own build cache entries most of them compile cold.

Because that is slow, contributors and coding agents split it into several processes (nsgo check -target web, nsgo check -target android_arm64, nsgo check -target linux_x64, … at once). Two things then go wrong:

  • Every nsgo check -target X first runs the host vet and, in the repository, both dev client vets (check.go:36-56) before checkTargets. Five processes run those three passes five times.
  • Nothing bounds the parallelism. Each go vet compiles with GOMAXPROCS workers, and two check processes in the same module do not know about each other.

Observed on a 12-core Apple M4 Pro: five concurrent nsgo check runs in the repository (-target all, web, android_arm64, linux_x64 and one more) put about 30 compile processes on the machine at once, CPU idle at 0% and the 1-minute load average at 440–500; the per-process CPU deltas showed the duplicated host go vet ./... under each -target X run.

Why it matters

AGENTS.md asks every change to be checked with go tool nsgo check (line 53), and the contributing guide offers only check and check -target all (docs/public/en/contributing.md:36-37). The tool gives no supported way to make the full check faster, so the natural workaround — more processes — repeats work and saturates the machine for everything else on it (other builds, simulators, the IDE).

Proposal

  1. When -target is given, let the host and dev client vets be skipped, either by default for an explicit target list or behind a flag such as -targets-only, so nsgo check -target web vets only web.
  2. Add a parallelism flag (for example -jobs N) that check passes to go vet as -p N and uses to vet up to a bounded number of targets at once inside one process. One process with a bound is then the fast path, not several unbounded ones.
  3. Take a lock per module (for example under .nsgo/) for the duration of check: a second check in the same module prints that another one (pid) is running and waits, rather than competing with it.
  4. Say in docs/public/en/contributing.md (and AGENTS.md) how to check locally: vet the platform you changed with -target <name>, give several targets to one process (-target a,b,c) rather than starting several, and leave the full matrix to check.yml, which already splits it between Linux and macOS.

Acceptance

  • nsgo check -target web (with the chosen flag, if it is not the default) runs no host or dev client vet.
  • nsgo check -target all -jobs 4 never runs more than 4 compile workers per go vet nor more than the given number of targets at once, and finishes faster than today's sequential run on a multi-core machine.
  • A second nsgo check started in the same module while one runs waits for it and says so.
  • The contributing guide describes the local check strategy above.

  • Platforms: all (the nsgo command)
  • NSGo: main at 7ec1e19 (2026-11-18)
  • Development machine: macOS 27.2 (Apple M4 Pro, 12 cores), Go 1.27.3

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions