Skip to content

Concurrently register spawn#4014

Merged
DrJosh9000 merged 1 commit into
mainfrom
concurrently-register-spawn
Jun 18, 2026
Merged

Concurrently register spawn#4014
DrJosh9000 merged 1 commit into
mainfrom
concurrently-register-spawn

Conversation

@DrJosh9000

Copy link
Copy Markdown
Contributor

Description

The workers are already started concurrently, but they weren't registered concurrently - until now!

Context

It annoyed me.

Changes

  • Add a concurrently package and a generic Map function. I'm sure we can reuse this. I'm also sure there are plenty of packages out there that could do this for us but wanted to write it out myself.
  • Use concurrently.Map to perform concurrent register calls.

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go tool gofumpt -extra -w .)

Disclosures / Credits

I did not use any AI tools to write this code.

@DrJosh9000 DrJosh9000 requested review from a team as code owners June 18, 2026 02:23
@DrJosh9000 DrJosh9000 added the feature New user-facing feature! label Jun 18, 2026
@DrJosh9000 DrJosh9000 force-pushed the concurrently-register-spawn branch 2 times, most recently from 20ffab7 to ce2fddb Compare June 18, 2026 03:23
@buildsworth-bk-app

Copy link
Copy Markdown

On it! Follow along with my review here: https://buildkite.com/buildkite/buildsworth-review-pull-request/builds/871

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a few issues that look load-bearing for making registration concurrent: the per-spawn request data is not preserved, and the shared registration client has mutable state that this path now exercises concurrently.

Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:

Download the buildsworth logs from build 871, then answer my questions about the findings.

Comment thread clicommand/agent_start.go Outdated
Comment thread clicommand/agent_start.go Outdated
Comment thread clicommand/agent_start.go
Comment thread internal/concurrently/map.go
@DrJosh9000 DrJosh9000 force-pushed the concurrently-register-spawn branch 3 times, most recently from 4f2feac to d45b931 Compare June 18, 2026 03:42
@DrJosh9000

Copy link
Copy Markdown
Contributor Author

@buildsworth-bk review

@buildsworth-bk-app

Copy link
Copy Markdown

On it! Follow along with my review here: https://buildkite.com/buildkite/buildsworth-review-pull-request/builds/874

@buildsworth-bk-app buildsworth-bk-app Bot dismissed their stale review June 18, 2026 04:12

Previous concerns have been addressed.

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous blocking concerns look addressed: spawn interpolation is back to the 1-based index, the concurrent callback now uses its per-spawn request, and registration response headers are applied to each per-agent client instead of mutating the shared registration client. I left one non-blocking edge case on the new worker-count option; since this changes registration-path concurrency, I’m leaving this as a comment review rather than an AI-only approval.

Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:

Download the buildsworth logs from build 874, then answer my questions about the findings.

Comment thread internal/concurrently/map.go Outdated
@DrJosh9000 DrJosh9000 force-pushed the concurrently-register-spawn branch from d45b931 to 0fea6e5 Compare June 18, 2026 04:28
@DrJosh9000

Copy link
Copy Markdown
Contributor Author

@buildsworth-bk review

@buildsworth-bk-app

Copy link
Copy Markdown

On it! Follow along with my review here: https://buildkite.com/buildkite/buildsworth-review-pull-request/builds/879

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The worker-count edge case from the previous pass looks addressed. I found one small CLI-input edge case in the registration setup; because this changes the agent registration path, I’m leaving this as a comment review rather than an AI-only approval.

Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:

Download the buildsworth logs from build 879, then answer my questions about the findings.

Comment thread clicommand/agent_start.go
@DrJosh9000 DrJosh9000 force-pushed the concurrently-register-spawn branch from 0fea6e5 to 0874325 Compare June 18, 2026 04:50
@DrJosh9000

Copy link
Copy Markdown
Contributor Author

@buildsworth-bk review

@DrJosh9000 DrJosh9000 force-pushed the concurrently-register-spawn branch from 0874325 to 4fc761b Compare June 18, 2026 04:51
@buildsworth-bk-app

Copy link
Copy Markdown

On it! Follow along with my review here: https://buildkite.com/buildkite/buildsworth-review-pull-request/builds/881

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous non-blocking notes around WithWorkerCount(0) and negative --spawn look addressed in the current diff. I didn't find any new inline findings; because this changes the agent registration path and API-client header transfer behavior, I'm leaving this as a comment review rather than an AI-only approval.

Want to dig deeper? The full session log is attached to this Buildkite build. Download the session file and open a new pi session with it:

Download the buildsworth logs from build 881, then answer my questions about the findings.

@zhming0 zhming0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Comment on lines +77 to +79
outMu.Lock()
out[work.idx] = o
outMu.Unlock()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically those goroutines aren't overlapping, we might not need outMu

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the element size is not a multiple of the CPU word size, then there may be a data race, because in order to write an element the goroutine has to write into a neighbouring element at the same time.

Comment thread internal/concurrently/map.go
@DrJosh9000 DrJosh9000 force-pushed the concurrently-register-spawn branch from 4fc761b to e68b587 Compare June 18, 2026 05:28
@DrJosh9000 DrJosh9000 force-pushed the concurrently-register-spawn branch from e68b587 to a59df3f Compare June 18, 2026 05:32
@DrJosh9000 DrJosh9000 enabled auto-merge June 18, 2026 05:34
@DrJosh9000 DrJosh9000 merged commit d616615 into main Jun 18, 2026
4 checks passed
@DrJosh9000 DrJosh9000 deleted the concurrently-register-spawn branch June 18, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New user-facing feature!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants