Skip to content

Multithreaded support via Numba's nogil #194

Description

@AndreasMadsen

It would be nice if queries could be executed in parallel. A simple solution is to do it multithreaded. However, for multithreading to be meaningful the GIL needs to be released. I think bm25s is almost there, since it already uses njit from numba heavily. The only remaining thing is to add nogil=True to njit().

https://numba.pydata.org/numba-doc/dev/user/jit.html

I can see that _retrieve_internal_jitted_parallel already does parallel=True, which can be a different way to achieve parallelization. However, this is a batched parallelization. What I'm looking for is a version of _retrieve_internal_jitted_parallel that does a single observation with nogil=True. Then I can run it asynchronously with asyncio.to_thread or similar.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions