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

Use Rayon for escore algorithm guessing. #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ZakisM
Copy link

@ZakisM ZakisM commented Mar 14, 2022

Hey, so I tried using Rayon inside the escore algorithm guess method.

I was able to get quite a nice speedup on my 4 core PC:

Benchmark 1: roget_old.exe
  Time (mean ± σ):      3.778 s ±  0.036 s    [User: 0.005 s, System: 0.004 s]
  Range (min … max):    3.708 s …  3.821 s    10 runs

Benchmark 2: roget_new.exe
  Time (mean ± σ):     650.0 ms ±  11.2 ms    [User: 1.3 ms, System: 6.8 ms]
  Range (min … max):   633.3 ms … 662.5 ms    10 runs

Summary
  'roget_new.exe' ran
    5.81 ± 0.11 times faster than 'roget_old.exe'

However, I noticed that each time I run the program with these changes the score is slightly different, i'm assuming that i'm doing something incorrect with Atomics?

@jonhoo
Copy link
Owner

jonhoo commented Mar 15, 2022

Hi! Thanks for contributing :)

I think I'd approach this slightly differently — rather than having the threads all communicate using atomics, instead have each thread operate completely independently and compute their own "best" candidate, and then do a quick (single-threaded) pass at the end that just finds the best among those found by each thread. I think you should be able to do that just with rayon (probably using something like ParallelIterator::reduce).

Also, I just landed some pretty big restructuring changes on main, so you may want to do your changes on top of that instead :)

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.

2 participants