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

Get rid of ThreadsX? #67

Open
gdalle opened this issue Jun 28, 2023 · 1 comment
Open

Get rid of ThreadsX? #67

gdalle opened this issue Jun 28, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@gdalle
Copy link
Member

gdalle commented Jun 28, 2023

We can speed up loading of InferOpt by replacing ThreadsX with built-in threads:

res = ThreadsX.map(f(i) for i in 1:n)

would become

f1 = f(1)
res = Vector{typeof(f1)}(undef, n)
res[1] = f1
@threads for i in 2:n
    res[i] = f(i)
end

Downsides:

  • less readable code
  • performance hit due to the first element: complexity 1 + (n-1)/t instead of n/t for t threads

Upsides:

  • less dependencies, faster loading of InferOpt
  • improved type stability?
@gdalle gdalle added the enhancement New feature or request label Jun 28, 2023
@gdalle
Copy link
Member Author

gdalle commented Jun 28, 2023

Also beware that @threads sometimes introduces type instabilities due to boxing

JuliaLang/julia#41731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant