I hope you enjoyed this section on concurrency.
We will now be going over the solution to the assignment for this section.
The question was using Rayon for this solution research.
Rayon join.
Once you have read into rayon, join in the Fibonacci join function of the provided source code.
Create a solution that utilizes rayon join so that we can see a performance enhancement in our Fibonacci
solution.
So once you research rayon join, you took away some information where rayon join takes two closures
and then possibly runs them in parallel.
In this case, they will be ran in parallel and then join is going to return a pair of the results from
those closures.
So we know that we're going to get some values back from the two closures.
So we'll create a tuple that is going to store values A and B and we're going to call Rayon join.
And we know that Rayon join once two closures.
So we'll give it this closure where we're going to call the Fibonacci recursive function.
And in here we're going to pass in N minus one.
And now we know that we need to pass in another closure and this time we will pass in N minus two.
And then simply all we have to do is add A plus B, so now we can run this and we see that in our first
iteration of fib recursive, which is the non parallel ized function, we see that Fibonacci recursive
actually takes a decent bit of time to actually execute because what it's doing is it's creating our
series of numbers for us and it happens to be pretty intensive computation.
So we see we get a really large number here and it took us 18 and one half seconds, but when we ran
it with Range join therefore introducing some parallelism, we were able to knock off a little over
6 seconds and still generate the correct solution.
So hopefully this is an eye opening assignment on how much time can be saved when you introduce some
parallelism into your solutions.
So I hope this assignment was fun for you and I will see you in the next section.