Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize decide_worker #4332

Merged
merged 11 commits into from
Dec 9, 2020
Merged

Optimize decide_worker #4332

merged 11 commits into from
Dec 9, 2020

Commits on Dec 9, 2020

  1. Annotate deps as a set

    jakirkham committed Dec 9, 2020
    Configuration menu
    Copy the full SHA
    082055e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4b0f8ff View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    edb5995 View commit details
    Browse the repository at this point in the history
  4. Assign ws with result and then return

    Helps Cython verify that this matches the expected `return` type before
    `return`ing.
    jakirkham committed Dec 9, 2020
    Configuration menu
    Copy the full SHA
    fc6a55e View commit details
    Browse the repository at this point in the history
  5. Just use a for-loop to extract first item

    This winds up being a bit faster than calling `first`.
    
    ```python
    In [1]: from tlz import first
    
    In [2]: s = {"a"}
    
    In [3]: %timeit first(s)
    76 ns ± 0.17 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
    
    In [4]: %%timeit
       ...: for e in s:
       ...:     break
       ...:
    42.4 ns ± 0.429 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
    ```
    jakirkham committed Dec 9, 2020
    Configuration menu
    Copy the full SHA
    13a7fc2 View commit details
    Browse the repository at this point in the history
  6. Deduplicate decide_worker branches

    As the case where there are idle workers and when there are not are
    largely the same (except with collection of workers they draw from),
    choose between the two collections at the beginning. Then spend the
    remainder of the code on the selection logic.
    jakirkham committed Dec 9, 2020
    Configuration menu
    Copy the full SHA
    7745b9e View commit details
    Browse the repository at this point in the history
  7. Assign len(worker_pool) to a variable

    Since we use this in a couple of cases, go ahead and assign it to a
    variable initially and reuse that variable afterwards.
    jakirkham committed Dec 9, 2020
    Configuration menu
    Copy the full SHA
    0ca489c View commit details
    Browse the repository at this point in the history
  8. Rename worker to ws

    As this variable refers to a `WorkerState` instance, rename it to follow
    the convention we have with `WorkerState` variable names.
    jakirkham committed Dec 9, 2020
    Configuration menu
    Copy the full SHA
    a41ccbc View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    3d493a6 View commit details
    Browse the repository at this point in the history
  10. Assign ws None and return in the first case

    Makes it easier for Cython to identify that this has the expected return
    type when checking the value returned.
    jakirkham committed Dec 9, 2020
    Configuration menu
    Copy the full SHA
    1f7fdad View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    b94310f View commit details
    Browse the repository at this point in the history