Skip to content

API to introspect the scope of what thread pool limit set/get API actually does #211

Closed

Description

@itamarst

There are two things to introspect:

  1. Does setting the thread pool limit affect only the current thread, or the whole process?
  2. If it affects the whole process, is it setting a per-thread limit for the whole process (what MKL does) or is changing the size of a process-wide global thread pool (OpenBLAS with pthreads)? UPDATE: This part is now in API to introspect semantic meaning of setting a thread pool limit #214.

Use cases for introspection:

  • Ensuring documentation on individual controllers is correct.
  • A debugging tool for users, both of their current setup, and of potential bugs in threadpoolctl.
  • Maybe: Getting a sense of what the current FlexiBLAS backend is actually doing when you tell it to set a limit. Given different OpenBLAS behaviors depending on its threading backend, and given limits of FlexiBLAS introspection, this may need to be done at runtime...

Activity

  1. itamarst commented on Jun 22, 2026

    @itamarst
    ContributorAuthor

    For introspection item 2, global thread pool vs per-thread thread pool... I can't think of way to introspect this, so far. So might have to drop that.

  2. ogrisel commented on Jun 23, 2026

    @ogrisel
    Contributor

    For introspection item 2, global thread pool vs per-thread thread pool... I can't think of way to introspect this, so far. So might have to drop that.

    Couldn't we hard code known semantics of various libraries / threading layer combinations and then use tests that spawn subprocesses and dynamically inspect the effective to check that we hardcoded is actually correct?

    We can return some "unknown" marker for libraries we have never seen in the past.

  3. itamarst commented on Jun 23, 2026

    @itamarst
    ContributorAuthor

    Somewhat, yes. But... you'd need to somehow figure out which Python library is using it and and where it's being used and someplace it'll be used with a suitable number of threads.

    Or maybe... For BLAS maybe you can use ctypes to dynamically run a test (and hope it uses all threads). I guess that's fine for documentation use case, adequate for user introspecting/debugging, and probably a bit too much for the FlexiBLAS use case. But that last one isn't high priority.

    OpenMP... compile something? You'd need the relevant compiler and libraries available, so it's maybe ok for documentation, and adequate for very motivated developers of libraries, but probably not feasible for most users.

    And registered controllers would be out of scope for this issue, at least.

  4. itamarst commented on Jun 23, 2026

    @itamarst
    ContributorAuthor

    The above is complex and speculative enough that I'm going to suggest this issue focus just on introspection item 1, and then open a new issue for introspection item 2.

  5. changed the title [-]API to introspect what a thread pool limit set/get API actually does[/-] [+]API to introspect the scope of what thread pool limit set/get API actually does[/+] on Jun 23, 2026
  6. itamarst commented on Jun 23, 2026

    @itamarst
    ContributorAuthor

    Draft PR is finding new information, e.g. it's claiming OpenMP on Windows is process-wide scope: https://github.com/joblib/threadpoolctl/actions/runs/28056951772/job/83061664809?pr=213

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