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

🕵️ parallel MinMaxDownsampler with x does not scale well to large n_out #14

Closed
jvdd opened this issue Jan 16, 2023 · 0 comments · Fixed by #15
Closed

🕵️ parallel MinMaxDownsampler with x does not scale well to large n_out #14

jvdd opened this issue Jan 16, 2023 · 0 comments · Fixed by #15
Assignees
Labels
enhancement New feature or request

Comments

@jvdd
Copy link
Member

jvdd commented Jan 16, 2023

We observe a significant (but constant) overhead when using MinMaxDownsampler

  • with x, and
  • with a large n_out, and
  • parallel=True

I believe the overhead in the parallel implementation with x originates from the use of independent (thread-safe) binary search in the index generator, which is performed twice (per bin) to find the start and end indices of each bin, resulting in a complexity of 2*n_out*log(n).
In comparison, the sequential implementation with x only performa binary search once (per bin) by utilizing the moving left value as the start of the bin and thus limiting the search area for the right index, resulting in a complexity of n_out*log(n/2).

Benchmarking results show that this overhead can be significant when downsampling to a n_out of 60k points, which is a common scenario when using the parallel MinMaxDownsampler with x in the MinMaxLTTB downsampler. (see below ⬇️ )

image

More detail (parallel vs sequential) and (with x vs without x)

image


I belueve that we should manage the number of threads ourselves as a solution, by creating a threadpool with the same number of threads as the number of CPUs available (as is done now). This would allow us to perform a subslice version of the sequential repeated binary search on each thread, utilizing the moving left advantages safely on a per thread basis.

@jvdd jvdd added the enhancement New feature or request label Jan 16, 2023
@jvdd jvdd self-assigned this Jan 16, 2023
@jvdd jvdd changed the title 🕵️ MinMaxAggregator with x does not scale well when using parallel = True 🕵️ parallel MinMaxDownsampler with x does not scale well to large n_out Jan 16, 2023
@jvdd jvdd closed this as completed in #15 Jan 17, 2023
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

Successfully merging a pull request may close this issue.

1 participant