Skip to content

fix(cli): bound concurrent target checks - #673

Merged
houko merged 3 commits into
nsgo-dev:mainfrom
houko:fix/check-target-jobs
Nov 18, 2026
Merged

houko merged 3 commits into
nsgo-dev:mainfrom
houko:fix/check-target-jobs

Conversation

@houko

@houko houko commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Implements #652.

  • check -target vets only the requested targets; the host vet and, in NSGo's repository, the dev-client vets belong to the plain check (which test.yml still runs).
  • -jobs n vets up to n targets at once and passes -p n to every go vet the check runs. Without it a check vets one target at a time with go's own -p, as before, so the default never runs more compilers than it used to; -jobs below 0 is refused.
  • Checks of one module serialize through the operating system's lock on .nsgo/check.lock at the module's root (flock, LockFileEx on Windows). A waiting check prints once which pid it waits for; a crashed or killed check's lock is released with its process, and an interrupted wait returns.
  • Target outcomes are reported in the targets' order whatever finishes first, a failing target does not stop the others, and cancellation starts no more.
  • The contributing guide (en and zh), the NSGo skill, AGENTS.md and docs/architecture/tool.md describe the local check strategy: name every touched target in one check -target a,b -jobs n rather than starting several checks.

Verification

  • go build ./...; go vet ./cmd/nsgo for windows amd64/386/arm64, linux arm64, android arm64, js/wasm and freebsd; go build ./cmd/nsgo for solaris (no-lock fallback).
  • go tool nsgo check, go tool nsgo check -target all -jobs 4 (Linux, 75 s; Apple mobile targets skipped there) and go tool nsgo check -target ios,ios_simulator,tvos,tvos_simulator,watchos,watchos_simulator -jobs 3 on macOS.
  • go tool nsgo test ./cmd/nsgo (310 passed, 14 skipped) and go tool nsgo test -run 'Layer|Skills|Doc' .; the new check tests also on macOS and Windows.
  • New tests: the host vet is skipped for an explicit target, -jobs bounds both concurrent targets and -p, the default runs one target at a time without -p, a second check waits and names the holder, and a stale lock file holds no later check.
  • Windows 11: two nsgo.exe check processes in one module; the second printed another nsgo check (pid 4700) is checking .; waiting for it and ran after the first.

Closes #652

@github-actions github-actions Bot added the conflict Conflicts with the base branch; resolve it first label Nov 18, 2026
@houko
houko force-pushed the fix/check-target-jobs branch from 2f337d6 to e67fb95 Compare November 18, 2026 10:52
@github-actions github-actions Bot added size/M documentation Improvements or additions to documentation cli bug Something isn't working and removed conflict Conflicts with the base branch; resolve it first labels Nov 18, 2026
@houko
houko force-pushed the fix/check-target-jobs branch 2 times, most recently from 39ac4bf to 53f44fe Compare November 18, 2026 19:13
@github-actions github-actions Bot added size/L and removed size/M labels Nov 18, 2026
@houko

houko commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed. All four points of #652's Acceptance are met: -target skips the host and dev-client vets, -jobs n bounds both the targets run at once and each vet's -p, a second check waits and names the first one's pid, and the docs say so (the zh debugging page is fixed in 53f44fe). Each new test fails when its fix is broken on purpose. Two real nsgo check processes wait for each other and recover after the first is killed, on Linux, macOS (flock) and Windows 11. CI is green on 53f44fe; the one earlier failure was TestWebInput in the macOS gallery job, which this command-line change cannot reach, and it passed on rerun.

…by -p

The check lock was an O_EXCL file that a killed or crashed check left behind, so every later check in the module waited forever; it is now flock (LockFileEx on Windows) on .nsgo/check.lock at the module's root, released with the process, and the waiting note names the holder's pid once. -jobs defaulted to half the CPUs for both target concurrency and go vet -p, which ran up to NumCPU²/4 compile workers for -target all and halved the plain check's own vet; without -jobs a check now vets one target at a time with go's default, as before. The worker bound is passed as vet arguments rather than through a context value, -jobs below 0 is refused, and the test command's -target help that the branch had reverted is restored. Tests cover the skipped host vet, the -jobs bounds, the lock's wait and a stale lock file; contributing (en, zh), the skill, AGENTS.md and the tool's architecture describe the result.
@houko
houko force-pushed the fix/check-target-jobs branch from 53f44fe to 75394ca Compare November 18, 2026 23:06
@houko

houko commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main to resolve a conflict in the test -target flag help (kept main's wording from #716; this PR does not change that line). CI is green on 75394ca after a rerun of the TestCanvasImageCacheKeepsAWidePass flake (#715, #738).

@houko
houko merged commit c77c542 into nsgo-dev:main Nov 18, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cli documentation Improvements or additions to documentation size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant