Skip to content

Optimize parallel workers start-up#21203

Open
ilevkivskyi wants to merge 4 commits intopython:masterfrom
ilevkivskyi:parallel-startup
Open

Optimize parallel workers start-up#21203
ilevkivskyi wants to merge 4 commits intopython:masterfrom
ilevkivskyi:parallel-startup

Conversation

@ilevkivskyi
Copy link
Copy Markdown
Member

@ilevkivskyi ilevkivskyi commented Apr 11, 2026

This is a micro-optimization that gives fixed 50-100ms performance improvement. It is mostly important for "simple" runs, where one only modifies few files. Such runs are often sub-second, where this will be a visible win.

Two ideas here:

  • Start workers in background, but don't wait for them to become ready until they are actually needed.
  • Broadcast graph/SCCs data to all workers in parallel.

I am actually not 100% sure about second one, but I guess it should help in big code-bases. IIUC sockets are I/O, so it should be possible to speed it up using threads. I am also adding a bit more logging, so that we get more insight into communication overhead.

cc @JukkaL

@github-actions

This comment has been minimized.

@ilevkivskyi
Copy link
Copy Markdown
Member Author

I decided to also increase our read size limit (just in case). Btw this makes me think that maybe we should set the same socket buffer size on Mac and Linux. On Linux it is fixed to 212992 bytes. While on Mac it is flexible/floating between 8192 bytes (checked using s.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF) on a fresh socket), and 8388608 bytes (value of sysctl kern.ipc.maxsockbuf). What may be happening is that Mac gets seriously confused trying to adjust buffer size, since we periodically sent very small (few bytes) and very large (few megabytes) payloads. So we may want to limit this behavior by setting some large lower limit with setsockopt(). Anyway, I will probably try this later in a separate PR.

@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant