Skip to content

Conversation

@bhearsum
Copy link
Contributor

@bhearsum bhearsum commented Oct 24, 2025

This adds experimental, opt-in support for generating kinds in parallel across multiple threads. When used in conjunction with a free-threaded python it can be a significant speed-up in configuration with many expensive to generate kinds (eg: Gecko) where multiprocessing is not available.

In the short and medium term this should stay opt-in for a few reasons:

  • It's slower than using multiprocessing
  • It's pointless, and potentially even harmful, to enable when not using a free-threaded python
  • Free threaded python is not widely supported yet. One implication here is that wheels of some packages we depend on (eg: zstandard) are not available, which makes taskgraph more painful to install with this python.

In the long term, I hope to get rid of multiprocessing support entirely once the above are no longer issues, because it imposes many limitations on how taskgraph generation can happen, how cached data can be shared, etc.

Ideally this PR would come with some multithreaded testing on Windows and macOS. Once #869 is done we ought to be able to add mac tests. Windows is trickier -- we don't have a compiler available on the workers, and zstandard (and probably other packages) don't have wheels available for free threaded python, which means we can't even install taskgraph in a free-threaded python virtualenv.

The code coverage failure is a bit misleading -- there's little in the way of new code here, and the new paths for the Linux side is covered with the multithread test job, which coverage isn't aware of.

@bhearsum bhearsum force-pushed the push-yvzvqryxtvsq branch 2 times, most recently from 2a48d4e to 05e295a Compare October 24, 2025 19:26
@abhishekmadan30
Copy link
Contributor

abhishekmadan30 commented Oct 24, 2025

Msgspec does support freethreading in python: https://github.com/jcrist/msgspec/pull/877/files

Initially thought we are planning to have both support for msgspec and voluptuous

@bhearsum
Copy link
Contributor Author

Msgspec does support freethreading in python: https://github.com/jcrist/msgspec/pull/877/files

Initially thought we are planning to have both support for msgspec and voluptuous

Oh, that's wonderful to hear about msgspec! Supporting both should be fine as far as I'm concerned for this work; it just means I'll need to rebase this after the schema work lands.

@ofek
Copy link

ofek commented Nov 24, 2025

msgspec support for 3.14 has been released https://github.com/jcrist/msgspec/releases/tag/0.20.0

@bhearsum bhearsum force-pushed the push-yvzvqryxtvsq branch 5 times, most recently from 4b13fb9 to 2afc838 Compare February 13, 2026 01:02
This will make a subsequent commit that adds support for a ThreadPoolExecutor cleaner.
Voluptuous contains thread-unsafe code; work around this by locking before calling into it.
Even with 3.14 free-threaded python, this is still a bit slower than multiprocessing on Linux, but it will allow us to start experimenting with it more, and may allow users on macOS and Windows to immediately see a speed-up.
@bhearsum bhearsum marked this pull request as ready for review February 13, 2026 01:30
@bhearsum bhearsum requested a review from a team as a code owner February 13, 2026 01:30
@bhearsum bhearsum requested a review from jcristau February 13, 2026 01:30
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.

3 participants