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

[Threadpool] Remove reserve threads #223

Merged
merged 7 commits into from
Feb 24, 2023
Merged

[Threadpool] Remove reserve threads #223

merged 7 commits into from
Feb 24, 2023

Conversation

mratsim
Copy link
Owner

@mratsim mratsim commented Feb 24, 2023

This removes a significant threadpool perf pessimization introduced in #222

  • reserve threads are removed.
  • some perf was also lost because:
    • primitives.nim was imported and it needed globals for CPU features detection. Unsure how this exactly slowed a benchmark down though.
    • creating a task is inlined for spawn (but not for loops as those requires more initialization)
    • the conditional branch in sync was a debugging aid and is not needed

An additional slight optimization is avoiding syscalls in wake when we have sleepy workers that are not yet asleep. The change in epoch is sufficient to avoid their sleep.

Finally, the stealHalf and adaptative theft policy code has been removed as it was never finished.

@mratsim
Copy link
Owner Author

mratsim commented Feb 24, 2023

Benchmarks

While many are unaffected, some are showing dramatic improvements

Log-sum-exp (up to 58x speedup)

Yup 58x speedup

Before
image

after
image

Heat diffusion (7.11x faster)

Before
image

After
image

Depth-First Search (up to 2x speedup)

Before
image

After
image

Fibonacci (1.45x faster)

Before
image

After
image

Crypto bench (6x improvement)

Focus on batch elliptic addition / sum reduction of 65536 BLS12-381 points

Before image

After
image

The pessimization code was slower than serial while after fix the code is 5.9x faster than serial

@mratsim mratsim merged commit 1dfbb8b into master Feb 24, 2023
@mratsim mratsim deleted the remove-reserve-threads branch February 25, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant